1

On my start page I have a product slider block where I show categories. Now I would like to have a category that is not in the menu but in the slide.

Problem is that if disable the category of set include_in_menu to false I don't get the category in the slider. Here is the slider query:

    $_helper = Mage::helper('catalog/category');
    $children = $_helper->getStoreCategories(false, true, false)
        ->addAttributeToSelect('product_slider')
        ->addAttributeToFilter('product_slider', array('neq' => ''))
        ->addAttributeToFilter('path', array('like' => "1/{$rootCategoryId}/%"))
        ->addOrderField('product_slider')
        ->addOrderField('name');

How do I get a catgory with include_in_menu = false.

2

PiTheNumber you cannot get include_in_menu category using this code... try this

 $category=Mage::getModel('catalog/category')->load(Mage::app()->getStore()->getRootCategoryId());
$children = Mage::getResourceModel('catalog/category_collection)->addAttributeToSelect('url_key')
            ->addAttributeToSelect('*')
            ->addAttributeToSelect('all_children')
            ->addAttributeToFilter('is_active', 1)
            ->addIdFilter($category->getChildren())
            ->setOrder('position', Varien_Db_Select::SQL_ASC)
            ->joinUrlRewrite()
            ->load();
| improve this answer | |
  • If I replace $_helper->getStoreCategories(false, true, false) with Mage::getResourceModel('catalog/category_collection') it works. Just found that out myself, too. Thanks! – PiTheNumber Sep 3 '14 at 7:39
0

Try using:

->addAttributeToFilter('include_in_menu', array('eq' => '0'))
| improve this answer | |
0

the definition of the fonction

getStoreCategories($sorted=false, $asCollection=false, $toLoad=true)

You want the method to return a collection that hasn't been loaded yet, thus the false, true, false arguments. Before you loop through the categories you want to make sure the image attribute is loaded as well, this is what the addAttributeToSelect('...') call is for.

Try with getStoreCategories(false, true, true)

| improve this answer | |
  • This takes forever and fully loads all categories but not the ones with include_in_menu = false. But worth the try, thank you! – PiTheNumber Sep 3 '14 at 7:42

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.