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 controller problem
 
Gregory Tonon
Member
 
Avatar
Total Posts:  65
Joined:  2008-03-27
Toulouse
 

Hello;

I try to override the Checkout/Onepage Controller, but i have small problem.

My new controller works with both action of checkout/onepage ( i display message in conscturctor and it’s work ) but with successAction, failureAction my template is broken ( instead of displaying 2-colums with message of confirmation/fail i have 3-colums without a message.

config.xml

<config>
    <
modules>
        <
Ekinos_Ekicheckout>
            <
version>1.0</version>
        </
Ekinos_Ekicheckout>
    </
modules>
    <global>
        <
rewrite>
            <
ekinos_ekicheckout_onepage>
                <
from><![CDATA[#^/checkout/onepage#]]></from>
                
<to>/ekicheckout/onepage</to>
            </
ekinos_ekicheckout_onepage>
        </
rewrite>
        <
blocks>
            <
checkout>
                <
rewrite>
                    <
cart_sidebar>Ekinos_Ekicheckout_Block_Cart_Sidebar</cart_sidebar>
                </
rewrite>
            </
checkout>
        </
blocks>
    </global>
    <
frontend>
        <
routers>
            <
ekinos_ekicheckout>
                <use>
standard</use>
                <
args>
                    <
module>Ekinos_Ekicheckout</module>
                    <
frontName>ekicheckout</frontName>
                </
args>
            </
ekinos_ekicheckout>
        </
routers>
    </
frontend>
</
config>

my new controller

<?php
require_once 'Mage/Checkout/controllers/OnepageController.php';
class 
Ekinos_EkiCheckout_OnepageController extends Mage_Checkout_OnepageController
{
    
public function saveOrderAction()
    
{
        $this
->_expireAjax();

        
$result = array();
        try 
{
            
if ($requiredAgreements Mage::helper('checkout')->getRequiredAgreementIds()) {
                $postedAgreements 
array_keys($this->getRequest()->getPost('agreement', array()));
                if (
$diff array_diff($requiredAgreements$postedAgreements)) {
                    $result[
'success'false;
                    
$result['error'true;
                    
$result['error_messages'$this->__('Please agree to all Terms and Conditions before placing the order.');
                    
$this->getResponse()->setBody(Zend_Json::encode($result));
                    return;
                
}
            }
            
if ($data $this->getRequest()->getPost('payment'false)) {
                $this
->getOnepage()->getQuote()->getPayment()->importData($data);
            
}
            $this
->getOnepage()->saveOrder();
            
$redirectUrl $this->getOnepage()->getCheckout()->getRedirectUrl();
            
/*Commentaires clients*/
            
$order Mage::getModel'sales/order' )->load$this->getOnepage()->getCheckout()->getLastOrderId() );
            
$order->setFlag_export(0);
            if( 
$this->getRequest()->getParam'customer_comment' ) ){
                $order
->setCustomer_comment$this->getRequest()->getParam'customer_comment' ) );
                
$order->addStatusToHistory(
                  
$order->getStatus(),
                    
Mage::helper('checkout')->__('Customer add the following comment : '.$this->getRequest()->getParam'customer_comment' ) )
                   );
            
}
            $order
->save();
            
            
$result['success'true;
            
$result['error']   false;
        
}
        
catch (Mage_Core_Exception $e{
            Mage
::logException($e);
            
$result['success'false;
            
$result['error'true;
            
$this->sendPaymentFaildEmail($e->getMessage());
            
$result['error_messages'$e->getMessage();
        
}
        
catch (Exception $e{
            Mage
::logException($e);
            
$result['success']  false;
            
$result['error']    true;
            
$this->sendPaymentFaildEmail($e->getMessage());
            
$result['error_messages'$this->__('There was an error processing your order. Please contact us or try again later.');
        
}

        
/**
         * when there is redirect to third party, we don't want to save order yet.
         * we will save the order in return action.
         */
        
if (isset($redirectUrl)) {
            $result[
'redirect'$redirectUrl;
        
}

        $this
->getResponse()->setBody(Zend_Json::encode($result));
    
}
  }

Any idea to solve this problem ?

Image Attachments
FireShot capture #48 - 'Synphonat' - users_ekinos_users_g_tonon_www_P-Synphonat_checkout_onepage_failure.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
KeyboardCowboy
Member
 
Total Posts:  65
Joined:  2008-07-01
Berlin, Germany
 

I got the same problem… any solutions for this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
retif
Sr. Member
 
Total Posts:  171
Joined:  2008-08-16
Odessa, Ukraine
 

you should check your xml config file

 
Magento Community Magento Community
Magento Community
Magento Community
 
KeyboardCowboy
Member
 
Total Posts:  65
Joined:  2008-07-01
Berlin, Germany
 

i cant find an error… can you post your config.xml please?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jimhoyd
Jr. Member
 
Total Posts:  10
Joined:  2008-12-11
 

did anyone find a solve for this? I have the same issue

 
Magento Community Magento Community
Magento Community
Magento Community
 
myrk
Jr. Member
 
Total Posts:  7
Joined:  2008-04-21
 

Yeah I found the solution, It was in checkout.xml in layout. You need to put these code in.

<Mycompany_modules_checkout_onepage_index>
<update handle="checkout_onepage_index"/>
</Mycompany_modules_checkout_onepage_index>

<Mycompany_modules_checkout_onepage_success>
<update handle="checkout_onepage_success"/>
</Mycompany_modules_checkout_onepage_success>

 
Magento Community Magento Community
Magento Community
Magento Community
 
ilovemagento
Member
 
Total Posts:  40
Joined:  2009-02-04
 

thanks for this solution

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