Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento rewrite core model resource collection

Im trying to rewrite the Mage_Review_Model_Resource_Review_Summary_Collection. The Module is activated. The folde structure is the same as in core review.

The problem should be in the xml.

My xml is:

<?xml version="1.0"?>
<config>
<modules>
    <LM_Review>
        <version>0.1.0</version>
    </LM_Review>
</modules>

<frontend>
    <routers>
        <review>
            <args>
                <modules>
                    <lm_review before="Mage_Review">LM_Review</lm_review>
                </modules>
            </args>
        </review>
    </routers>

    <layout>
        <updates>
            <lm_review>
                <file>lm/review.xml</file>
            </lm_review>
        </updates>
    </layout>

    <translate>
        <modules>
            <LM_Review>
                <files>
                    <default>LM_Review.csv</default>
                </files>
            </LM_Review>
        </modules>
    </translate>
</frontend>

<global>
    <models>
        <review_resource>
            <rewrite>
                <review_summary_collection>LM_Review_Model_Resource_Review_Summary_Collection</review_summary_collection>
            </rewrite>
        </review_resource>
    </models>
</global>
</config>

LM_All.xml in etc/modules

<LM_Review>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Review />
            </depends>
</LM_Review>

The Collection.php in app/code/local/LM/Review/Model/Resource/Review/Summary/Collection.php

class LM_Review_Model_Resource_Review_Summary_Collection extends Mage_Review_Model_Resource_Review_Summary_Collection {

   public function addStoreFilter($storeId) {
      die('test');
   }

}
like image 260
exe Avatar asked Apr 09 '13 15:04

exe


1 Answers

Your XML is correct. With the above XML in place, if you make the factory method call

Mage::getResourceModel('review/review_summary_collection') 

Magento will attempt to instantiate a

LM_Review_Model_Resource_Review_Summary_Collection

That means

  1. Magento can't see your module (no app/etc/module file, or file is inactive, or file is pointing to the wrong code pool)

  2. You do not have a file at LM/Review/Model/Resource/Review/Summary/Collection.php in your code pool

  3. The class defined in Collection.php is not LM_Review_Model_Resource_Review_Summary_Collection

  4. The class defined in Collection.php does not extend Mage_Review_Model_Resource_Review_Summary_Collection

  5. Check the spelling and upper/lower case of your class and path names. This matters to Magento.

like image 126
Alan Storm Avatar answered Sep 18 '22 16:09

Alan Storm