1

NOTE: This is Magento 1.4. Because of the complex configuration of some of our products, I'm having to route the wishlist function addAction() over to the app/code/local section of Magento. However, the reroute is not taking effect. Here is what I have done:

  1. created this folder/file: app/code/local/Mycompany/Wishlist/etc/config.xml

inside I have this code:

<?xml version="1.0" ?>
<config>
    <modules>
        <Mycompany_Wishlist>
            <version>0.1.0</version>
        </Mycompany_Wishlist>
    </modules>
    <frontend>
        <routers>
            <wishlist>
                <args>
                    <modules>
                        <Mycompany_Wishlist>Mycompany_Wishlist</Mycompany_Wishlist>
                    </modules>
                </args>
            </wishlist>
        </routers>
    </frontend>
</config>
  1. created this folder/file: app/code/local/Mycompany/controllers/IndexController.php

with this code:

require_once 'Mage/Wishlist/controllers/IndexController.php';
class Mycompany_Wishlist_IndexController extends Mage_Wishlist_IndexController
{
    /**
     * Adding new item
     */
    public function addAction()
    {
        exit('hello world, I'm in the new file!');
        $session = Mage::getSingleton('customer/session');
        $wishlist = $this->_getWishlist();
        if (!$wishlist) {
            $this->_redirect('*/');
            return;
        }
        .. etc. ..

I HAVE CLEARED MY CACHE. Why is the new file not being recognized?

1 Answer 1

2

I hope this will be helpful to someone. I made the following two changes to get it to work:

First: added a file app/code/etc/modules/Mycompany_Wishlist.xml so that Mage could recognize the router (and of course cleared my cache):

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_Wishlist>
            <active>true</active>
            <codePool>local</codePool>
        </Mycompany_Wishlist>
    </modules>
</config>

Second: added before="Mage_Wishlist" in the XML - see pasted code below - as it appears that without this, the native code is overriding.

<?xml version="1.0" ?>
<config>
    <modules>
        <Mycompany_Wishlist>
            <version>0.1.0</version>
        </Mycompany_Wishlist>
    </modules>
    <frontend>
        <routers>
            <wishlist>
                <args>
                    <modules>
                        <Mycompany_Wishlist before="Mage_Wishlist">Mycompany_Wishlist</Mycompany_Wishlist>
                    </modules>
                </args>
            </wishlist>
        </routers>
    </frontend>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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