_categoryHelper = $categoryHelper; $this->categoryFlatConfig = $categoryFlatState; $this->topMenu = $topMenu; parent::__construct($context); } /** * Return categories helper */ public function getCategoryHelper() { return $this->_categoryHelper; } /** * Return categories helper * getHtml($outermostClass = '', $childrenWrapClass = '', $limit = 0) * example getHtml('level-top', 'submenu', 0) */ public function getHtml() { return $this->topMenu->getHtml(); } /** * Retrieve current store categories * * @param bool|string $sorted * @param bool $asCollection * @param bool $toLoad * @return \Magento\Framework\Data\Tree\Node\Collection|\Magento\Catalog\Model\Resource\Category\Collection|array */ public function getStoreCategories($sorted = false, $asCollection = false, $toLoad = true) { return $this->_categoryHelper->getStoreCategories($sorted , $asCollection, $toLoad); } /** * Retrieve child store categories * */ public function getChildCategories($category) { if ($this->categoryFlatConfig->isFlatEnabled() && $category->getUseFlatResource()) { $subcategories = (array)$category->getChildrenNodes(); } else { $subcategories = $category->getChildren(); } return $subcategories; } public function getChildCategoryHtml($category, $icon_open_class="porto-icon-plus-squared", $icon_close_class="porto-icon-minus-squared") { $html = ''; if($childrenCategories = $this->getChildCategories($category)) { $html .= '