0

I need category list with the help of attribute for creating custom menu visible in all pages.

I have created a drop-down category attribute. I would like to display all the categories for one on the values in the drop-down. Actually I want to display all the values but separately, that way I can create four columns of category listings.

I can display the attribute on the category page but i need to be able to echo the list on all the pages.

I have one parent category id

and attribute detail :

Attribute code: enter image description here

attribute value

enter image description here]2

i want category list as per attribute id. Means which category product have attribute 0-3 Months, will list

1 Answer 1

0

you can try below code for that.

    $collection = Mage::getModel('catalog/category')->getCollection()
                  ->addAttributeToFilter('age',array('eq' => '0 - 3 Months'));//change value as per yours
    foreach($collection as $category){
        print_r($category->getData());
    }

If above code not work then try below code

$attr = 'age';
$_category = Mage::getModel('catalog/category');
$attr = $_category->getResource()->getAttribute($attr);
if ($attr->usesSource()) {
    $option_id = $attr->getSource()->getOptionId("0 - 3 Months");//change value as per yours
}

    $collection = Mage::getModel('catalog/category')->getCollection()
                  ->addAttributeToFilter('age',array('eq' => $option_id));
    foreach($collection as $category){
        print_r($category->getData());
    }
4
  • thanks! Fatal error: Call to a member function getBackend() on boolean in app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 816
    – Byndd IT
    Sep 22, 2016 at 10:55
  • its product attribute or category attribute? Sep 22, 2016 at 11:03
  • check new answer and if its not work tell me I will give you another solution Sep 22, 2016 at 11:11
  • Fatal error: Call to a member function usesSource() on boolean in app/design/frontend/ibees/default/template/page/html/header.phtml on line 344
    – Byndd IT
    Sep 22, 2016 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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