Frage

In order to develop an automated order status changer based on payment method and event type, I created the following module:

/GT/OrderFlo/etc/config.xml

    <!--?xml version="1.0"?-->
<config>
    <modules>
        <gt_orderflow>
            <version>1.0</version>
        </gt_orderflow>
    </modules>

    <global>

        <models>            
            <orderflow>
                <class>GT_OrderFlow_Model</class>
            </orderhook>
        </models>

        <events>
            <sales_order_place_after>
                <observers>
                    <order_payment_pending_autostatus>
                        <type>singleton</type>
                        <class>orderflow/observer</class>
                        <method>implementOrderStatus</method>
                    </order_payment_pending_autostatus>
                </observers>
            </sales_order_place_after>
            <sales_order_shipment_save_after>
                <observers>
                    <order_invoice_pending_autostatus>
                        <type>singleton</type>
                        <class>orderflow/observer</class>
                        <method>implementOrderStatus</method>
                    </order_invoice_pending_autostatus>
                </observers>
            </sales_order_shipment_save_after>
            <sales_order_invoice_save_commit_after>
                <observers>
                    <order_complete_autostatus>
                        <type>singleton</type>
                        <class>orderflow/observer</class>
                        <method>implementOrderStatus</method>
                    </order_complete_autostatus>
                </observers>
            </sales_order_invoice_save_commit_after>                        
        </events>

    </global>
</config>

/GT/OrderFlow/Model/Observer.php

class GT_OrderFlow_Model_Observer
{
public function implementOrderStatus($event)
{
    $order = $event->getOrder();
    $payment_method = $this->_getPaymentMethod($order);
    $this->_log('In implementOrderStatus with payment method: '.$payment_method);
    Mage::log('In implementOrderStatus with payment method: '.$payment_method);
    $next_status = "";
    return $this;
}

private function _getPaymentMethod($order)
{
    return $order->getPayment()->getMethodInstance()->getCode();
}

private function _log($message)
{
    return Mage::log($message, null, 'gt_orderflow.log');
}
}

The code was replicated from http://www.atwix.com/magento/auto-invoice-and-custom-order-status-upon-checkout/.

But how can I get it to fire the observer after sales_order_place_after event?

War es hilfreich?

Lösung

Is your module loaded at all? You will need a file in /app/etc/modules. On a related note, I see that you refer to your module as <gt_orderflow> but the class prefix is GT_OrderFlow. On a case sensitive filesystem, this is important and will not work this way. The nodes under config/modules are mapped to the module path.

Andere Tipps

I think you have a typo

<models>             
    <orderflow>  
    -----^
        <class>GT_OrderFlow_Model</class>
    </orderhook>
    -----^
</models>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top