简体   繁体   中英

Why is my Magento Catalog ProductController not being extended?

I'm trying to extend my Magento Catalog ProductController View (to be precise Mage_Checkout_CartController::ViewAction) and Magento does not seem to be acknowledging the module extension.

So I have the following files:

This is the /app/code/local/Mage/SwapMachine/etc/config.xml config file

    <?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Mage_SwapMachine>
            <version>0.1.0</version>
        </Mage_SwapMachine>
    </modules>
    <frontend>
        <routers>
            <swapmachine>
                <args>
                    <modules>
                        <Mage_SwapMachine before="Mage_Catalog">Mage_SwapMachine_Frontend</Mage_SwapMachine>
                    </modules>
                </args>
            </swapmachine>
        </routers>
    </frontend>
</config> 

This is the /app/design/frontend/base/default/layout/swapmachine.xml file. As I was instructed to create from Source #2 (Sources on bottom)

<?xml version="1.0"?>
<mage_swapmachine_frontend>
    <update handle="catalog_product_view"/>           
</mage_swapmachine_frontend>

This is the /app/code/local/Mage/SwapMachine/controllers/Frontend/ProductController.php file

    <?php
    include(Mage::getBaseDir()."/app/code/core/Mage/Catalog/controllers/ProductController.php");

class Mage_SwapMachine_Frontend_ProductController extends Mage_Catalog_ProductController
{

    public function viewAction()
    {
       /// Get initial data from request
        die("IT'S WORKING!");
    }

}

I have tried to fix the situation on my own for some week now and I feel at lost. I followed the information here first.

Source 1

Magento Catalog ProductController rewrite

After multiple attemps I later found this and tried the information here though it is for Magento 2.

Source 2

https://magento2.atlassian.net/wiki/display/m1wiki/How+To+Overload+a+Controller

As you are trying to override the catalog module, the XML should look like this:

<frontend>
    <routers>
        <catalog>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM