Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Override more than one action
 
Jonathan Moratelli
Member
 
Total Posts:  35
Joined:  2008-10-30
 

Some days before I needed override an action from a controller. I used this tutorial “http://www.magentocommerce.com/wiki/how_to_overload_a_controller” and all worked fine.

Now I need override a new action from the same controller, but not working.

Just one action was overwritten, the second action declared in config.xml

The code below:

Magento/app/code/local/Ofsrj/Clientetv/etc/config.xml

...
    <global>
        <!-- 
This rewrite rule could be added to the database instead -->
        <
rewrite>
            <!-- 
This is an identifier for your rewrite that should be unique -->
            <!-- 
THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
            <
ofsrj_clientetv_checkout_onepage>
                <
from><![CDATA[#^/checkout/onepage/saveShipping/$#]]></from>
                
<!--
                    - 
mymodule matches the router frontname below
                    
checkout_cart matches the path to your controller
                   
                    Considering the router below
"/mymodule/checkout_cart/" will be
                    
"translated" to "/MyNameSpace/MyModule/controllers/Checkout/CartController.php" (?)
                -->
                <
to>/clientetv/checkout_onepage/saveShipping/</to>
                <
from><![CDATA[#^/checkout/onepage/saveBilling/$#]]></from>
                
<to>/clientetv/checkout_onepage/saveBilling/</to>
            </
ofsrj_clientetv_checkout_onepage>
        </
rewrite>
...

In this case only saveBilling is overwritten. If I change de position only saveShipping is overwritten.

Anybody can help me???

 
Magento Community Magento Community
Magento Community
Magento Community
 
subesh
Sr. Member
 
Avatar
Total Posts:  145
Joined:  2009-01-08
 

try separating the two… write two <ofsrj_clientetv_checkout_onepage> Blocks....

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jonathan Moratelli
Member
 
Total Posts:  35
Joined:  2008-10-30
 

I just do that.

I also separated into two <Rewrite> tags but without success.

If anybody knows another way to do that, please help me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
subesh
Sr. Member
 
Avatar
Total Posts:  145
Joined:  2009-01-08
 

<rewrite>
<
ofsrj_clientetv_checkout_onepage_saveshipping>
                <
from><![CDATA[#^/checkout/onepage/saveShipping/$#]]></from>
                
<!--
                    - 
mymodule matches the router frontname below
                    
checkout_cart matches the path to your controller
                   
                    Considering the router below
"/mymodule/checkout_cart/" will be
                    
"translated" to "/MyNameSpace/MyModule/controllers/Checkout/CartController.php" (?)
                -->
                <
to>/clientetv/checkout_onepage/saveShipping/</to>
             </
ofsrj_clientetv_checkout_onepage_saveshipping>

<
ofsrj_clientetv_checkout_onepage_savebilling>
                 <
from><![CDATA[#^/checkout/onepage/saveBilling/$#]]></from>
                
<to>/clientetv/checkout_onepage/saveBilling/</to>             
             </
ofsrj_clientetv_checkout_onepage_savebilling>

</
rewrite>

Did you write this way.. with different blocks name… and save the config and clear the cache .. and check .......... if it didn’t work then I know no other way. sorry...... : (

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jonathan Moratelli
Member
 
Total Posts:  35
Joined:  2008-10-30
 

Thankyou subesh.

Now all works fine!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
MI
Sr. Member
 
Total Posts:  172
Joined:  2008-12-11
Spain
 

I want to add a new method to CartController but I don’t know how to do that in local folder.
Please help me!

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jonathan Moratelli
Member
 
Total Posts:  35
Joined:  2008-10-30
 

You need to overload de Controller, use this tutorial: http://www.magentocommerce.com/wiki/how_to_overload_a_controller

Ask me if you have any doubt.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MI
Sr. Member
 
Total Posts:  172
Joined:  2008-12-11
Spain
 

Thanks Jonathan! But I have used that tutorial and it doesn’t work. My method is never called :-( :-(

 
Magento Community Magento Community
Magento Community
Magento Community
 
mirelon
Member
 
Total Posts:  41
Joined:  2008-11-04
 

I have the same problem. I want to override saveBilling action from checkout/onepage and i tried that tutorial and also this thread. But still is only the original method called.
My config.xml looks like this:

<config>
 <
modules>
  <
Mage_Mycheckout>
   <
version>0.9.2</version>
  </
Mage_Mycheckout>
 </
modules>
<
frontend>

 <
routers>
  <
mage_mycheckout>
   <use>
standard</use>
    <
args>
     <
module>Mage_Mycheckout</module>
     <
frontName>mycheckout</frontName>
    </
args>
   </
mage_mycheckout>
  </
routers>
 </
frontend>

 <global>
  <
rewrite>
   <
mage_mycheckout_checkout_onepage>
    <
from><![CDATA[#^/checkout/onepage/saveBilling/#]]></from>
    
<to>/mycheckout/checkout_onepage/saveBilling/</to>
   </
mage_mycheckout_checkout_onepage>
  </
rewrite>
 </global>
</
config>

and also app/etc/moduiles/Mage_Mycheckout.xml is also ok, the proof is in admin: sysem > configuration > advanced, it is listed as enabled.
And yes, I have file app/code/local/Mage/Mycheckout/controllers/OnepageController.php that has

require_once 'Mage/Checkout/controllers/OnepageController.php';
class 
Mage_Mycheckout_OnepageController extends Mage_Checkout_OnepageController{
 
public function saveBillingAction(){
  
...
 
Magento Community Magento Community
Magento Community
Magento Community
 
mirelon
Member
 
Total Posts:  41
Joined:  2008-11-04
 

I finally managed to do it, but i am not fully satisfied by this solution:
in config.xml i removed the <rewrite> part
in admin > catalog > url rewrite management i added rewrite from checkout/onepage/saveBilling to mycheckout/onepage/saveBilling
I had to do it for every store!
Does anyone know some similar way how to do this invariant to change of number of stores?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top