0

I am stuck with this, I want show Layered navigation for all sub category.

My "Is Anchor" For all sub category is enabled to Yes. Please suggest me way how I can show this.

Code for _getItemsData-->

    protected function _getItemsData() {

    if ($_module = Mage::app()->getRequest()->getModuleName() == "catalogsearch")
        return $this->_getItemsDataSearch();
    $key = $this->getLayer()->getStateKey() . '_SUBCATEGORIES';
    $data = $this->getLayer()->getAggregator()->getCacheData($key);

    if ($data === null) {
        $category = $this->getCategory();
        /** @var $categoty Mage_Catalog_Model_Categeory */
        $categories = $this->_getChildrenCategories($category);
         //$this->getLayer()->getProductCollection()
              // ->addCountToCategories($categories);
        $data = array();
        foreach ($categories as $category) {
            if ($category->getIsActive()) {
                $_count = Mage::getModel('catalog/layer')->setCurrentCategory($category)->getProductCollection()->getSize();
                //$_count = $category->getProductCount() ;
                //Mage::getModel('catalog/layer')->setCurrentCategory($category)->getProductCollection()->getSize();
                if (!Mage::getStoreConfig("ajaxlist/ajaxlist/show_no_count") && !$_count) {
                    continue;
                }
                $data[] = array(
                    'label' => Mage::helper('core')->htmlEscape($category->getName()),
                    'value' => $category->getId(),
                    'count' => $_count,
                );
            }
        }
        $tags = $this->getLayer()->getStateTags();
        $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
    }
    return $data;
}

Image 1- I want to show category as appear on Image 1 to Image 2

Image 2 is coming from dreamscapes.html it is sub sub category from Theme

Image1

Image 2 Without category

0

I got the solution for this. See Below code

protected function _getItemsData() {
    if ($_module = Mage::app()->getRequest()->getModuleName() == "catalogsearch")
        return $this->_getItemsDataSearch();
    $key = $this->getLayer()->getStateKey() . '_SUBCATEGORIES';
    $data = $this->getLayer()->getAggregator()->getCacheData($key);
    if ($data === null) {
        $category = $this->getCategory();
        /** @var $categoty Mage_Catalog_Model_Categeory */

          if($categories==null)
        {

               $rootcatId  = Mage::app()->getStore()->getRootCategoryId();
               $root_cat   = Mage::getModel('catalog/category')->load($rootcatId);
                $cat_model = Mage::getModel('catalog/category');
                $categories = $cat_model->load($root_cat->getId())->getChildrenCategories();

        }
        else
        {
        $categories = $this->_getChildrenCategories($category); 
      }
         //$this->getLayer()->getProductCollection()
              // ->addCountToCategories($categories);
        $data = array();
        foreach ($categories as $category) {
            if ($category->getIsActive()) {
                $_count = Mage::getModel('catalog/layer')->setCurrentCategory($category)->getProductCollection()->getSize();
                //$_count = $category->getProductCount() ;
                //Mage::getModel('catalog/layer')->setCurrentCategory($category)->getProductCollection()->getSize();
                if (!Mage::getStoreConfig("ajaxlist/ajaxlist/show_no_count") && !$_count) {
                    continue;
                }
                $data[] = array(
                    'label' => Mage::helper('core')->htmlEscape($category->getName()),
                    'value' => $category->getId(),
                    'count' => $_count,
                );
            }
        }
        $tags = $this->getLayer()->getStateTags();
        $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
    }
    return $data;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.