i try to rewrite /app/code/core/Mage/Review/Model/Resource/Review/Collection.php and /app/code/core/Mage/Review/Model/Resource/Review.php
step 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>
step 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>
step3:
/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;
}
}
i do not know what the problem is !
Close. The collection rewrite is a bit off:
step 2 : /app/code/local/Lbb/Review/etc/config.xml
<?xml version="1.0"?>
<config>
<global>
<models>
<review_resource>
<rewrite>
<review_collection>Lbb_Review_Model_Resource_Review_Collection</review_collection>
</rewrite_resource>
</review>
</models>
</global>
</config>
This will work for Magento CE1.6+ / EE1.11+, BTW.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With