阅读96 返回首页    go 阿里云 go 技术社区[云栖]


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

  上一篇:go Aix related
  下一篇:go magento -- 如何为商品分类(category)添加自定义属性