$product = Mage::getModel('catalog/product');
$storeId = Mage::app()->getStore()->getId();
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setStoreId($storeId);
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer') // This can be changed to any attribute code
->load(false);
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
/* @var $attribute Mage_Eav_Model_Entity_Attribute */
$manufacturers = $attribute->getSource()->getAllOptions(false);
return $manufacturers;
这应该这样做。您可以降低要选择的属性。
$product = Mage::getModel('catalog/product');
$products = $product->setStoreId($storeId)->getCollection()
->addAttributeToSelect(array('name', 'price', 'small_image','short_description','manufacturer'), 'inner');
$this->setProductCollection($products);
谢谢,但使我有以下错误:致命错误:调用未定义的方法Mage_Eav_Model_Mysql4_Entity_Attribute_Collection :: addStoreFilter()。有什么想法吗? – sulman
我添加了setStoreId而不是addStoreFilter,请立即尝试。如果这不起作用,您将需要更改我们正在处理的集合。我会添加另一个选项。 –
谢谢,但我无法让它工作。 TBH我认为这个处理时间可能太重,因为我会把它放在主页上。想想我最终会手动添加制造商。不过谢谢。 – sulman