0

支払い方法とイベント タイプに基づいて自動注文ステータス チェンジャーを開発するために、次のモジュールを作成しました。

/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');
}
}

コードはhttp://www.atwix.com/magento/auto-invoice-and-custom-order-status-upon-checkout/から複製されました。

sales_order_place_afterしかし、イベント後にオブザーバーを起動するにはどうすればよいですか?

4

2 に答える 2

0

タイプミスがあると思います

<models>             
    <orderflow>  
    -----^
        <class>GT_OrderFlow_Model</class>
    </orderhook>
    -----^
</models>
于 2013-01-22T23:53:53.150 に答える
0

モジュールはまったくロードされていますか? のファイルが必要になります/app/etc/modules。関連するメモとして、モジュールを として参照しているようです<gt_orderflow>が、クラスの接頭辞はGT_OrderFlow. 大文字と小文字を区別するファイルシステムでは、これは重要であり、この方法では機能しません。下のノードconfig/modulesは、モジュール パスにマップされます。

于 2013-01-22T23:02:59.237 に答える