1

I have created a module for listening to the event sales_order_place_after. I did it following the article http://www.atwix.com/magento/auto-invoice-and-custom-order-status-upon-checkout.

I use it for set my order to processing status, because it's always changed to pending that I set with new order status.

The module works in Magento 1.8.0, but it doesn't work in magento 1.9.1. How could I resolve this problem? Please help me

This is how the module is built:

  1. First, I create a module initializer in /app/etc/modules/Atwix_Orderhook.xml with following content

    <?xml version="1.0"?>
    <config>
        <modules>
            <Atwix_Orderhook>
                <active>true</active>
                <codePool>community</codePool>
            </Atwix_Orderhook>
        </modules>
    </config>
    
  2. then I create a module configuration file /app/code/community/Atwix/Orderhook/etc/config.xml with content

    <?xml version="1.0"?>
    <config>
        <modules>
            <Atwix_Orderhook>
                <version>1.0</version>
            </Atwix_Orderhook>
        </modules>
    
        <global>
    
            <models>            
                <orderhook>
                    <class>Atwix_Orderhook_Model</class>
                </orderhook>
            </models>
    
            <events>
                <sales_order_place_after>
                    <observers>
                        <auto_invoice_order>
                            <type>singleton</type>
                            <class>Atwix_Orderhook_Model_Observer</class>
                            <method>implementOrderStatus</method>
                        </auto_invoice_order>
                    </observers>
                </sales_order_place_after>
            </events>
    
        </global>
    </config>
    
  3. finally I create the app/code/community/Atwix/Orderhook/Observer.php with following content

    <?php
    
    class Atwix_Orderhook_Model_Observer 
    {
        public function implementOrderStatus($event)
        {
            $order = $event->getOrder();
            if ($this->_getPaymentMethod($order) == 'cwinline') {
                $this->_processOrderStatus($order);
            }
            return $this;
        }
    
        private function _getPaymentMethod($order){        {
            return $order->getPayment()->getMethodInstance()->getCode();
        }
    
        private function _processOrderStatus($order){
            $status = $order->getPayment()->getStatus();
            if($status=='SUCCESS'){
                $this->_changeOrderStatus($order);
            }
            return true;
        }
    
        private function _changeOrderStatus($order){
        $statusMessage = 'payment success';
        $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING,Mage_Sales_Model_Order::STATE_PROCESSING,$statusMessage, false);        
        $order->save();
        }
    }
    ?>
    
  • it's hard to pinpoint the issue without looking at the code, are you using the code exactly as it shows on the article? Do you get any error in the logs? The event name is the same in 1.9.1 so the must be something wrong elsewhere. – Javier Villanueva Sep 11 '15 at 9:25
  • I will update my question right now,hold on please. – kyo Sep 11 '15 at 9:30
  • 4
    Path of the observer is wrong, it should be app/code/community/Atwix/Orderhook/Model/Observer.php, You are missing Model – Nasir Perwaiz Sep 11 '15 at 9:59
  • 1
    @NasirPerwaiz, please write your comment as an answer as it provides the solution to the OP's question. Thanks! – 7ochem Sep 11 '15 at 13:59
  • 1
    @NasirPerwaiz, agree with 7ochem, you should write it as answer, then OP can mark it as correct answer if that has helped him. Cheers. – Adarsh Khatri Sep 11 '15 at 14:24
4

As suggested by 7ochem and Adarsh Khatri I am writing my answer, The path to your observer Model is wrong. It should be,

app/code/community/Atwix/Orderhook/Model/Observer.php

Thanks,

1

The node in your config.xml file should be placed in a new

<frontend> node under </global>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.