96
技術社區[雲棲]
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);
原文地址:https://magentocookbook.wordpress.com/2010/03/04/magento-get-all-products-by-attribute-set/
最後更新:2017-04-02 04:26:01