Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The important action of setting the order status is handled in Mage_Sales_Model_Order_Payment::Place():</p> <pre><code>... $orderState = Mage_Sales_Model_Order::STATE_NEW; ... $orderStatus = $methodInstance-&gt;getConfigData('order_status'); ... $order-&gt;setState($orderState, $orderStatus, $message, $isCustomerNotified); ... </code></pre> <p>However, in Mage_Sales_Model_Order::setState(), it doesn't check for relationship between order state and order status. Hence, the <em>weird hybrid</em>.</p> <p>There are many ways to work around this, one is to add observer for event 'checkout_type_onepage_save_order_after' and reset the status there. My preferred method is to add a callback in the payment method model:</p> <pre><code>class Celera_AaCredit_Model_Payment extends Mage_Payment_Model_Method_Abstract { protected $_code = 'aa_credit'; protected $_isInitializeNeeded = true; //Required for the initialize() callback to happen /* Workaround to assign the correct order state to the corresponding status set in system config */ /** * Invoke in Mage_Sales_Model_Order_Payment * Required for the initialize() callback to happen * * @return string */ public function getConfigPaymentAction() { return 'init'; //set flag to initialize $this after order is created and the payment is placed } /** * Update order state to system configuration * * @return Mage_Payment_Model_Method_Abstract */ public function initialize($action, $stateObject) { if ($status = $this-&gt;getConfigData('order_status')) { $stateObject-&gt;setStatus($status); $state = $this-&gt;_getAssignedState($status); $stateObject-&gt;setState($state); $stateObject-&gt;setIsNotified(true); } return $this; } /** * Get the assigned state of an order status * * @param string order_status */ protected function _getAssignedState($status) { $item = Mage::getResourceModel('sales/order_status_collection') -&gt;joinStates() -&gt;addFieldToFilter('main_table.status', $status) -&gt;getFirstItem(); return $item-&gt;getState(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload