這個代碼片段是一個例子來根據屬性組名稱擷取所有商品
//fetch attribute set id by attribute set name
$attrsetname = 'my_custom_attribute';
$attributesetid = mage::getmodel('eav/entity_attribute_set')
->load($attrsetname, 'attribute_set_name')
->getattributesetid();
//load product model collecttion filtered by attribute set id
$products = mage::getmodel('catalog/product')
->getcollection()
->addattributetoselect('name')
->addfieldtofilter('attribute_set_id', $attributesetid);
//process your product collection as per your bussiness logic
$productsname = array();
foreach($products as $p){
$productsname[] = $p->getdata('name');
}
//return all products name with attribute set 'my_custom_attribute'
print_r($productsname);
原文位址:http://magentocookbook.wordpress.com/2010/03/04/magento-get-all-products-by-attribute-set/