Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8186813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:21:11+00:00 2026-06-07T02:21:11+00:00

I want to overload the saveAction method from the core/Mage/Adminhtml/controllers/Catalog/ProductController.php and it won’t work

  • 0

I want to overload the saveAction method from the core/Mage/Adminhtml/controllers/Catalog/ProductController.php and it won’t work – I have now searched and tried for a complete day 🙁

Background: I want to change the value of a custom attribute before the saving of the product. I found out, that the _initProductSave sets the attributes and I think, that changing them after the init_ProductSave would be a good point (if anyone knows a better place, please let me know) …

MAY ANYONE PLEASE HELP ME … 🙂

Magento Version: Community Edition version 1.7.0.1
No Extension, no themes installed, I just installed this version completely blank …

VERSION 1: Overwritting the controller by copying to the local/Mage folder

First of all I tried to copy the file to the app/code/local folder, within the correct struture – but it won’t work (I have done this with the Varient.php for local testsystem and the stores.php for correcting the price bug – for both it’s working …)

VERSION 2: Overwritting the controller with an extension

My extension looks like this:

File structure:

code/local/MyOne/MyExtension/controllers/Catalog/ProductController.php 
code/local/MyOne/MyExtension/etc/config.xml 
etc/modules/MyOne_MyExtension.xml

The files look the following:
MyOne_MyExtension.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <MyOne_MyExtension>
            <active>true</active>
            <codePool>local</codePool>
        </MyOne_MyExtension>
    </modules>
</config>

code/local/MyOne/MyExtension/etc/config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <MyOne_MyExtension>
            <version>1.0.0</version>
        </MyOne_MyExtension>
    </modules>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <MyOne_MyExtension before="Mage_Adminhtml">MyOne_MyExtension_Catalog_ProductController</MyOne_MyExtension>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

and the last one, code/local/MyOne/MyExtension/controllers/Catalog/ProductController.php:

<?php
require_once 'Mage/Adminhtml/controllers/Catalog/ProductController.php';

class MyOne_MyExtension_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
{
    public function saveAction()
    {
        // do my stuff
        die('reached method');
        // after pressing on save, there should no be a white screen ...
    }
}
?>

I have googled and read that much, I do not see an error …

Any help would really be great !!!

Greetings,
matthias

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:21:13+00:00Added an answer on June 7, 2026 at 2:21 am

    NB: Given the method being targeted…

    Mage_Adminhtml_Catalog_ProductController->_initProductSave()
    

    …it would be best practice to rule out the use of an adminhtml-scoped observer consuming the catalog_product_save_before event.


    “First of all I tried to copy the file to the app/code/local folder, within the correct structure…”

    This is not an uncommon developer approach, but it will never work. Magento action controller classes are not loaded by the autoloader. They are explicitly loaded by their real filesystem path. Therefore, the so-called “include path hack” does not apply.

    Ref. Mage_Core_Controller_Varien_Router_Standard->getControllerFileName().

    Your second approach – performing a rewrite with a proper custom extension – is the correct approach. All you need is to understand how Magento finds action controller directories and matches action controller classes to the request URL.

    In its config.xml, the Mage_Adminhtml module configures the Admin router, which is responsible for matching all admin-related requests:

    <admin>
        <routers>
            <adminhtml>
                <use>admin</use>
                <args>
                    <module>Mage_Adminhtml</module>
                    <frontName>admin</frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
    

    The preceding configuration snippet does two things: the <frontName /> node adds a module route, and the <module /> node – along with the registered Mage_Adminhtml <codePool /> value (“core”) – establishes a directory in which action controller class may be found, in this case, /[basepath]/app/code/core/Mage/Adminhtml/controllers/.

    Module action controller rewrites work by adding other candidate matching directories to an existing module route. This is all parsed from the configuration:

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <MyOne_MyExtension before="Mage_Adminhtml">MyOne_MyExtension_Catalog_ProductController</MyOne_MyExtension>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    

    As can be seen, the above configuration simply adds or adds to the admin/routers/adminhtml/args/ node when the configuration XML is compiled. How this is interpreted and used for request matching is quite similar to the “normal” process of controller matching. In the above example, the MyOne_MyExtension module is effectively adding a directory to the list of directories for the Adminhtml module. Assuming it’s in the local codePool, the above example points to the directory

    /[basepath]/app/code/local/MyOne/MyExtension/controllers/Catalog/ProductController/
    

    This would work if there were an action controller class at

    /[basepath]/app/code/local/MyOne/MyExtension/controllers/Catalog/ProductController/Catalog/ProductController.php
    

    which contained a _initProductSave() method in a class named

    MyOne_MyExtension_Catalog_ProductController_Catalog_ProductController
    

    Hopefully this explanation is enough to see that config-based controller rewrites work at the directory level, rather than by specifying a particular class (which is how block, helper, and model rewrites work). Because this configuration adds a directory, it doesn’t have to result in a rewrite, as it can be used to simply add new actions for a given module. Ultimately, an action controller rewrite only occurs if some other controller class matches before the “original” controller class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Magento version 1.6 and I want to like overload a method in
I have a method which returns the base type, I want an overload (preferably,
I want to overload a cast operator, I have the following piece of code
I have a Card class and I want to overload the > operator to
Want to run javascript function from parent window in child window Example I have
I have a smart pointer class and I want to overload operator-> ; it's
I have a simple class for which I want to overload operator as below
I have a class that uses a struct, and I want to overload the
I have a custom collection and I want to overload the indexer. My problem
I want overload two method with one parameter, in a method varargs of String

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.