Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter collection by attribute Set

Tags:

php

magento

How would one filter collection by attribute set name

I am trying as following, but its not working

$collection->addAttributeToFilter('attribute_set_name',"Quantity Television Parts");

Thank You

like image 889
latvian Avatar asked Mar 12 '10 23:03

latvian


2 Answers

This is how i end up doing.

I looked up id of the attribute-set-name in the table "eav_attribute_set" table and used following filter:

$products->addAttributeToFilter('attribute_set_id','33');
like image 144
latvian Avatar answered Nov 06 '22 12:11

latvian


We can filter the collection by attribute set using:

addAttributeToFilter('attribute_set_id','attribute set id here');

suppose your attribute set id is 10.

For example

$collection = Mage::getModel('catalog/product')->getCollection();

$collection->addAttributeToFilter('status', array('eq' =>1))

           ->addAttributeToFilter('attribute_set_id','10')
           ->addAttributeToSelect('*');
like image 3
Kul Avatar answered Nov 06 '22 14:11

Kul