0

I'm trying to override some files of wishlist core module. This is my config.xml file:

<?xml version="1.0"?>
<config>
    <modules>
        <Srh_Wishlist>
            <version>0.1.0</version>
        </Srh_Wishlist>
    </modules>
    <frontend>
        <routers>
            <wishlist>
                <use>standard</use>
                <args>
                    <module>Srh_Wishlist</module>
                    <frontName>wishlist</frontName>
                </args>
            </wishlist>
        </routers>
    </frontend>
    <global>
        <rewrite>
            <Srh_wishlist_indexcontroller>
                <from><![CDATA[#^/wishlist/index/#]]></from>
                <!-- Mage_Wishlist_IndexController  -->
                <to>/wishlist/index/</to>
                <!-- Srh_Wishlist_IndexController  -->
            </Srh_wishlist_indexcontroller>
        </rewrite>
        <blocks>
            <wishlist>
                <class>Srh_Wishlist_Model</class>
            </wishlist>
            <wishlist>
                <rewrite>
                    <customer_wishlist>Srh_Wishlist_Block_Customer_Wishlist</customer_wishlist>
                </rewrite>
            </wishlist>
        </blocks>
        <models>
            <wishlist>
                <class>Srh_Wishlist_Model</class>
                <resourceModel>wishlist_mysql4</resourceModel>
            </wishlist>
            <wishlist_resource>
                <rewrite>
                    <item_collection>Srh_Wishlist_Model_Resource_Item_Collection</item_collection>
                </rewrite>
            </wishlist_resource>
            <wishlist>
                <rewrite>
                    <item>Srh_Wishlist_Model_Item</item>
                </rewrite>
            </wishlist>
            <wishlist>
                <rewrite>
                    <wishlist>Srh_Wishlist_Model_Wishlist</wishlist>
                </rewrite>
            </wishlist>
        </models>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <wishlist after="Mage_Adminhtml">Srh_Wishlist</wishlist>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

Apparently it works fine, but in system.log I have next problem:

Warning: include(Srh/Wishlist/Model/Observer.php): failed to open stream: No such file or directory in /var/www/html/magento/lib/Varien/Autoload.php on line 94

Warning: include(): Failed opening 'Srh/Wishlist/Model/Observer.php' for inclusion (include_path='/var/www/html/magento/app/code/local:/var/www/html/magento/app/code/community:/var/www/html/magento/app/code/core:/var/www/html/magento/lib:.:/usr/share/pear:/usr/share/php') in /var/www/html/magento/lib/Varien/Autoload.php on line 94

And in file exception.log:

exception 'Mage_Core_Exception' with message 'Invalid block type: Srh_Wishlist_Model_Links' in /var/www/html/magento/app/Mage.php:595

I don't want to override Model/Observer.php even Model/Links.php from Wishlist Magento module. Why Magento are throwing this errors? I have something wrong in my config.xml?

Thanks in advance!

0

You need edit config.xml this below.

You can read more about Overriding Block, Models, Helper,Controller in http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/

<?xml version="1.0"?>
   <config>
     <modules>
        <Srh_Wishlist>
            <version>0.1.0</version>
        </Srh_Wishlist>
     </modules>
     <frontend>
     <routers>
         <wishlist>
            <use>standard</use>
                <args>
                    <module>Srh_Wishlist</module>
                    <frontName>wishlist</frontName>
                    <srh_wishlist before="Mage_Wishlist">Srh_Wishlist</srh_wishlist>
                </args>
        </wishlist>
    </routers>
    </frontend>
    <global>
       <blocks>
           <wishlist>
               <class>Srh_Wishlist_Block</class>
           </wishlist>
           <wishlist>
               <rewrite>        
                 <customer_wishlist>Srh_Wishlist_Block_Customer_Wishlist</customer_wishlist>
               </rewrite>
          </wishlist>
      </blocks>
      <models>
        <wishlist>
            <class>Srh_Wishlist_Model</class>
        </wishlist>
        <wishlist_resource>
            <rewrite>
                <item_collection>Srh_Wishlist_Model_Resource_Item_Collection</item_collection>
            </rewrite>
        </wishlist_resource>
        <wishlist>
            <rewrite>
                <item>Srh_Wishlist_Model_Item</item>
            </rewrite>
        </wishlist>
        <wishlist>
            <rewrite>
                <wishlist>Srh_Wishlist_Model_Wishlist</wishlist>
            </rewrite>
        </wishlist>
     </models>
  </global>
  <admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <wishlist after="Mage_Adminhtml">Srh_Wishlist_Adminhtml</wishlist>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

0

You should use a different tag for your module's blocks, models, and helpers identifier since <wishlist> is already taken by Mage_Wishlist.

Best practice dictates you snake_case your module's namespace_modulename, so in your case, you should use <srh_wishlist>.

What's happening above is that you are declaring that the <wishlist> node should apply to your module, and thus Magento can't find the actual Mage_Wishlist blocks to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.