1
votes

I'm trying to add a custom action to a core controller by extending it in a local module. Below I have the class definition which resides in magento1_3_2_2/app/code/local/MyCompany/MyModule/controllers/Catalog/ProductController.php

class MyCompany_MyModule_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController                                                                                                                                                                                
{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  public function massAttributeSetAction(){
    ...
  }
}

Here is my config file at magento1_3_2_2/app/code/local/MyCompany/MyModule/etc/config.xml:

...
<global>
    <rewrite>                                                                                                                                                                                                                                                             
        <mycompany_mymodule_catalog_product>                                                                                                                                                                                                                                   
            <from><![CDATA[#^/catalog_product/massAttributeSet/#]]></from>                                                                                                                                                                                              
            <to>/mymodule/catalog_product/massAttributeSet/</to>                                                                                                                                                                                                           
        </mycompany_mymodule_catalog_product>                                                                                                                                                                                                                                  
    </rewrite>

    <admin>                                                                                                                                                                                                                                                                   
        <routers>                                                                                                                                                                                                                                                               
            <MyCompany_MyModule>                                                                                                                                                                                                                                                       
                <use>admin</use>                                                                                                                                                                                                                                                    
                <args>                                                                                                                                                                                                                                                              
                    <module>MyCompany_MyModule</module>                                                                                                                                                                                                                                    
                    <frontName>MyModule</frontName>                                                                                                                                                                                                                                      
                </args>                                                                                                                                                                                                                                                             
            </MyCompany_MyModule>                                                                                                                                                                                                                                                      
        </routers>                                                                                                                                                                                                                                                              
    </admin>
</global>
...

However, https://example.com/index.php/admin/catalog_product/massAttributeSet/ simply yields a admin 404 page. I know that the module is active - other code is executing fine. I feel it's simply a problem with my xml syntax. Am I going about this the write way? I'm hesitant because I'm not actually rewriting a controller method... I'm adding one entirely. However it does make sense in that, the original admin url won't respond to that action name and it will need to be redirected.

I'm using Magento 1.3.2.2

Thanks for any guidance.

1

1 Answers

2
votes

I don't have access to my Magento installs at the moment, but two things pop out

First, your write rule

[#^/catalog_product/massAttributeSet/]

Is saying "match any URL that starts with /catalog_product" and your question indicates you want to match a URL that begins with /admin/catalog_product.

Second, if you're using 1.3+ consider skipping the URL rewrite method and trying a "real" controller override instead.