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

Overriding Checkout/controlers/MultishippingController.php - how? - [SOLVED]
 
phlux0r
Member
 
Avatar
Total Posts:  73
Joined:  2008-03-09
Auckland, New Zealand
 

I’m trying to override the above mentioned controller in my own module to no avail. I only want to override the shippingPostAction() method. I have followed the hints in this thread: http://www.magentocommerce.com/boards/viewthread/15914/ and looked at Mage/Core/Controller/Varien/Action.php for hints too.

My controller class gets loaded when I click on Checkout with multiple addresses (as I put some debug info into my error log from Mage/Core/Controller/Varien/Router/Standard.php) however, the page gets redirected to the shopping cart page. I can’t understand why. Here’s my XML:

/app/code/local/MyModule/Deliverydate/etc/config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <
modules>
        <
MyModule_Deliverydate>
            <
version>0.1.0</version>
        </
MyModule_Deliverydate>
    </
modules>
    <global>
        <
routers>
            <
checkout>
                <
rewrite>
                    <
multishipping>
                        <
to>deliverydate/multishipping</to>
                        <
override_actions>true</override_actions>
                        <
shippingPost><to>deliverydate/multishipping/shippingPost</to></shippingPost>
                    </
multishipping>
                </
rewrite>
            </
checkout>
        </
routers>
         <
blocks>
            <
deliverydate>
                <class>
MyModule_Deliverydate_Block</class>
            </
deliverydate>
        </
blocks>
        <
models>
            <
deliverydate>
                <class>
MyModule_Deliverydate_Model</class>
            </
deliverydate>
             <
checkout>
                 <
rewrite>
                    <
type_multishipping>MyModule_Deliverydate_Model_Type_Multishipping</type_multishipping>
                </
rewrite>
            </
checkout>
        </
models>
    </global>
    <
frontend>
         <
routers>
            <
deliverydate>
                <use>
standard</use>
                <
args>
                    <
module>MyModule_Deliverydate</module>
                    <
frontName>deliverydate</frontName>
                </
args>
            </
deliverydate>
        </
routers>
        <
layout>
            <
updates>
                <
mymodule>
                    <
file>mymodule.xml</file>
                </
mymodule>
            </
updates>
        </
layout>
    </
frontend>
</
config>

And my /app/code/local/MyModule/Deliverydate/controllers/MultishippingController.php:

require_once 'Mage/Checkout/controllers/MultishippingController.php';
class 
Wildpoppies_Deliverydate_MultishippingController extends Mage_Checkout_MultishippingController
{
    
public function shippingPostAction()
    
{
        $shippingMethods 
$this->getRequest()->getPost('shipping_method');
        
// just adding some new fields here...
        
$customerNotes $this->getRequest()->getPost('customer_notes');
        
$deliveryDates $this->getRequest()->getPost('delivery_dates');
        
$deliveryTimes $this->getRequest()->getPost('delivery_times');
        
        try 
{
            Mage
::dispatchEvent(
                
'checkout_controller_multishipping_shipping_post',
                array(
'request'=>$this->getRequest(), 'quote'=>$this->_getCheckout()->getQuote())
            );
            
            
$this->_getCheckout()->setCustomerNotes($customerNotes);
            
$this->_getCheckout()->setDeliveryDates($deliveryDates$deliveryTimes);

            
$this->_getCheckout()->setShippingMethods($shippingMethods);
            
$this->_getState()->setActiveStep(
                
Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
            
);
            
$this->_getState()->setCompleteStep(
                
Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
            
);
            
$this->_redirect('*/*/billing');
        
}
        
catch (Exception $e){
            Mage
::getSingleton('checkout/session')->addError($e->getMessage());
            
$this->_redirect('*/*/shipping');
        
}
    }
}
Can anyone please give me a hint as to what’s wrong?
 
Magento Community Magento Community
Magento Community
Magento Community
 
subesh
Sr. Member
 
Avatar
Total Posts:  145
Joined:  2009-01-08
 

Your XML is wrong..

<rewrite>
 <
NameSpace_Module_to_class_METHOD>
    <
from><![CDATA[#^/to/class/METHOD/$#]]></from>
      
<to>/Module/to_class/METHOD</to>
 </
NameSpace_Module_to_class_METHOD
</
rewrite>
This is the way
 
Magento Community Magento Community
Magento Community
Magento Community
 
phlux0r
Member
 
Avatar
Total Posts:  73
Joined:  2008-03-09
Auckland, New Zealand
 

Thanks for that,

in the end I did it like that and it worked!

For the record, this is what I have in the config.xml now:

<rewrite>
            <
mycompany_delivery_multishipping>
                <
from><![CDATA[#^/checkout/multishipping/shippingPost/$#]]></from>
                
<to>/deliverydate/multishipping/shippingPost/</to>
            </
mycompany_delivery_multishipping>
        </
rewrite>
 
Magento Community Magento Community
Magento Community
Magento Community
 
MahendraDan
Member
 
Total Posts:  43
Joined:  2010-04-05
 

Hi ,

Where need to put the below code in the config.xml

<rewrite>
<mycompany_delivery_multishipping>
<from><![CDATA[#^/checkout/multishipping/shippingPost/$#]]></from>
<to>/deliverydate/multishipping/shippingPost/</to>
</mycompany_delivery_multishipping>
</rewrite>

I have tried but my controller method does not invoke using above code.

Could you please tell me where need the chages in the config.xml file.

Thanks

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