0
votes

In magento, I need to pull all categories that have text "test-category-block" in the description. I tried to add addFieldToFilter but doesn't work. Is there an easy way to do it?

Update:

Just found another question, this might help me: Magento categories listing using getCollection & addLevelFilter but exclude Default Root Category

SOLVED:

$_collection = Mage::getResourceModel('catalog/category_collection')
        ->addAttributeToSelect('*')
        ->addAttributeToFilter('level',array('gt' => 1))
        ->addAttributeToFilter('description', array('like' => '%category-search-filter%'));
1

1 Answers

2
votes

You probably want to do this to filter on text within the description field:

 $categories = Mage::getModel('catalog/category')->getCollection()
     ->addFieldToFilter('description', array('like' => '%test-category-block%'))

If you don't use the like array param, then it will do only match on descriptions that equal the provided value, not that contain it.