magento -- 如何获得某个属性组的所有商品

这个代码片段是一个例子来根据属性组名称获取所有商品

 

//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/

你可能感兴趣的:(magento -- 如何获得某个属性组的所有商品)