我在Magento CMS中遇到过这样的问题。我需要检索所有类别的制造商。 乍一看这不是问题,因为有一个过滤器块和图层导航从中你可以采取必要的方法。如何获得Magento中的所有制造商类别
首先我创建重新定义的分类模型/app/code/local/Mage/ Catalog/Model/Category.php
public function getManufacturers()
{
$collection = Mage::getResourceModel('catalog/product_attribute_collection')
->setItemObjectClass('catalog/resource_eav_attribute');
$setIds = $this->getProductCollection()->getSetIds();
$collection->getSelect()->distinct(true);
$collection
->setAttributeSetFilter($setIds)
->addStoreLabel(Mage::app()->getStore()->getId())
->setOrder('position', 'ASC');
$collection->addIsFilterableFilter();;
$collection->load();
return $collection;
}
的公共方法我在类模板调用这个方法:
$manufscturers = $_category->getManufacturers();
这样我们就得到了巨大的物体Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Collection
。
然后:
$items = $manufscturers->getItems();
而我们得到的对象Mage_Catalog_Model_Resource_Eav_Attribute
。
然后我不知道该怎么做。这是一个死路一条。也许这是错误的方式?
Magento的版本 - 1.4.0.1
感谢您的帮助!
你必须让所有的ID(已经有此)和查询属性的产品关系 – 2011-05-16 13:50:38
我需要的对象Mage_Catalog_Model_Resource_Eav_Attribute办呢? – 2011-05-16 14:01:55