Magento:无法覆盖资源模型。我做错了什么?



所以我想覆盖Mage_Lating_Model_Resource_Rating_Option_Vote_Collection类。

执行以下操作:

<config>
    ...
    <global>
        <models>
                <rating_resource>
                        <rewrite>             
                             <rating_option_vote_collection>Mycompany_Modulename_Model_Resource_Rating_Option_Vote_Collection</rating_option_vote_collection>
                        </rewrite>
                </rating_resource>
        </models>
    </global>
    ...
</config>

我也试过这个:

   <config>
        ...
        <global>
            <models>
                    <rating>
                            <rewrite> 
                                 <resource_rating_option_vote_collection>Mycompany_Modulename_Model_Resource_Rating_Option_Vote_Collection</resource_rating_option_vote_collection>
                            </rewrite>
                    </rating>
            </models>
        </global>
        ...
    </config>

我在上出错

Mage::getResourceModel('modulename/rating_option_vote_collection')

无论如何。

这里可能出了什么问题?

PS:缓存已关闭。

在粘贴的代码中,由于没有在<model>标记中放入任何...,因此没有定义模型的别名,因此用Mage::getResourceModel('modulename/rating_option_vote')调用它是不起作用的
尝试:

   <config>
        ...
        <global>
            <models>
               <modulename>
                   <class>Mycompany_Modulename_Model</class>
               </modulename>
                <rating>
                    <rewrite> 
                         <resource_rating_option_vote_collection>Mycompany_Modulename_Model_Resource_Rating_Option_Vote_Collection</resource_rating_option_vote_collection>
                    </rewrite>
                </rating>
            </models>
        </global>
        ...
    </config>

[EDIT:将此答案中的相关信息添加到问题中]

哎呀,我的错。我的错在

Mage::getResourceModel('modulename/rating_option_vote').

正确的代码是:

Mage::getResourceModel('modulename/rating_option_vote_collection');

相关内容

最新更新