0

I am trying to rewrite app/code/core/Mage/Adminhtml/contollers/Catalog/ProductController.php. In my config.xml I have the following:

<?xml version="1.0"?>
<config>
    <modules>
        <Product_CustomProduct>
            <version>0.1.0</version>
        </Product_CustomProduct>
    </modules>
    <admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Product_CustomProduct before="Mage_Adminhtml">Product_CustomProduct</Product_CustomProduct>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
</config>

and in app/code/local/Product/CustomProduct/controllers/Catalog/ProductController.php I have:

<?php
include_once("Mage/Adminhtml/controllers/Catalog/ProductController.php");

class Product_CustomProduct_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
{
    /**
     * Save product action
     */
    public function saveAction()
    {
        echo 123456;
        die;
    }
}

I want to change saveAction function of core controller. But after product save my file echo is not working. My module is displayu on admin and it is enable. I dont know why my code is not working.

My newAction also not changed dont understand what is wrong in my structure.I dont want to change core file of magento.

0

Put your controller file under an Admintml folder. Better to use a similar folder path of the class which you are going to override.

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Product_CustomProduct>
            <version>0.1.0</version>
        </Product_CustomProduct>
    </modules>
    <admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Product_CustomProduct before="Mage_Adminhtml">Product_CustomProduct_Adminhtml</Product_CustomProduct>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
</config>

and in app/code/local/Product/CustomProduct/controllers/Adminhtml/Catalog/ProductController.php

<?php
include_once("Mage/Adminhtml/controllers/Catalog/ProductController.php");

class Product_CustomProduct_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
{
    /**
     * Save product action
     */
    public function saveAction()
    {
        echo 123456;
        die;
    }
}
  • Not working for me. – Mathew Oct 23 '15 at 6:03
  • please check the system.log and/or exception.log for the possible errors – Manashvi Birla Oct 23 '15 at 6:04
  • Only Notice and Warnings are present and they are not related to new product module. – Mathew Oct 23 '15 at 6:12
  • My newAction also not changed dont undersatnd what is wrong in my structure. – Mathew Oct 23 '15 at 6:22

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.