我不得不改变Magento的Mage_Catalog_Model_Resource_Eav_Mysql4_Category类的方法。我已经改变:
public function getChildrenCategories($category)
{
$collection = $category->getCollection();
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('all_children')
->addAttributeToSelect('is_anchor')
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
->setOrder('position', 'ASC')
->joinUrlRewrite()
->load();
return $collection;
}
:
public function getChildrenCategories($category)
{
$collection = $category->getCollection();
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('all_children')
->addAttributeToSelect('thumbnail')
->addAttributeToSelect('is_anchor')
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
->setOrder('position', 'ASC')
->joinUrlRewrite()
->load();
return $collection;
}
基本上添加了->addAttributeToSelect('thumbnail')
,因为我需要获得该属性。
我现在卡住了如何安全地覆盖这个函数。我已经将整个类复制到local > Mage > Catalog > Model > Resouce > Eav > Mysql4 > Category.php
中,但实际上我只需要重写那个函数。
我该怎么做?
您必须覆盖模块中的整个资源集合。