我必须更改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
,但实际上我只需要覆盖那一个函数。
我该怎么做?