我尝试重写 /app/code/core/Mage/Review/Model/Resource/Review/Collection.php 和 /app/code/core/Mage/Review/Model/Resource/Review.php
第 1 步:/app/etc/modules/Lbb_Review.xml
<?xml version="1.0"?>
<config>
<modules>
<Lbb_Review>
<active>true</active>
<codePool>local</codePool>
</Lbb_Review>
</modules>
</config>
第 2 步:/app/code/local/Lbb/Review/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Lbb_Review>
<version>0.1.0</version>
</Lbb_Review>
</modules>
<global>
<models>
<review_resource>
<rewrite>
<review>Lbb_Review_Model_Resource_Review</review>
</rewrite>
</review_resource>
<review_resource_review>
<rewrite>
<collection>Lbb_Review_Model_Resource_Review_Collection</collection>
</rewrite>
</review_resource_review>
</models>
</global>
</config>
第三步:
/app/code/local/Lbb/Review/Model/Resource/Review.php
<?php
class Lbb_Review_Model_Resource_Review extends Mage_Review_Model_Resource_Review
{
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
echo 'test';
}
}
/app/code/local/Lbb/Review/Model/Resource/Review/Collection.php
<?php
class Lbb_Review_Model_Resource_Review_Collection extends Mage_Review_Model_Resource_Review_Collection
{
/**
* init select
*
* @return Mage_Review_Model_Resource_Review_Product_Collection
*/
protected function _initSelect()
{
parent::_initSelect();
$this->getSelect()
->join(array('detail' => $this->_reviewDetailTable),
'main_table.review_id = detail.review_id',
array('detail_id', 'title', 'detail', 'nickname', 'size', 'customer_id'));
return $this;
}
}
我不知道是什么问题!