Fetch a collection by custom filter in Magento

Example of fetching categories in Magento and filtering by a custom attribute:

$categories = Mage::getModel('catalog/category')->getCollection();
$categories->addAttributeToSelect('name');
$categories->addAttributeToFilter('featured_category', 1);
 
foreach($categories as $key => $category) {
	echo $category->getName();
}
This entry was posted in Magento and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">