簡體   English   中英

如何使用Magento中的擴展/模塊創建自定義訂單狀態

[英]How to create custom order status using an extension / module in Magento

我想知道是否有任何方法可以在Magento中創建自定義訂單狀態。 我正在開發一個Magento擴展程序,其中必須向磁電機訂單添加一些自定義訂單狀態。

我在Google上搜索了很多,但是沒有找到任何好的資源。

任何人都可以解釋如何執行此操作,請提供任何參考資源。

假設您要使用“授權”代碼添加“授權付款”狀態。

將以下內容添加到模塊的config.xml中的config / global下:

    <sales>
        <order>
            <statuses>
                <authorized translate="label">
                    <label>Authorized Payment</label>
                </authorized>
            </statuses>
            <states>
               <authorized translate="label">
                    <label>Authorized Payment</label>
                    <statuses>
                        <authorized default="1"/>
                    </statuses>
                    <visible_on_front>1</visible_on_front>                      
               </authorized>
            </states>
        </order>
    </sales>

以前足夠了,但是在最新版本(如果我沒記錯的話是1.5.xx)中,還需要以下位。 將以下內容添加到擴展的mysql設置/更新文件中:

<?php

$installer = $this;

$statusTable        = $installer->getTable('sales/order_status');
$statusStateTable   = $installer->getTable('sales/order_status_state');
$statusLabelTable   = $installer->getTable('sales/order_status_label');

$data = array(
    array('status' => 'authorized', 'label' => 'Authorized Payment')
);
$installer->getConnection()->insertArray($statusTable, array('status', 'label'), $data);

$data = array(
    array('status' => 'authorized', 'state' => 'authorized', 'is_default' => 1)
);
$installer->getConnection()->insertArray($statusStateTable, array('status', 'state', 'is_default'), $data);

?>

從技術上講,這將為您的系統添加新狀態。 現在,您可以將其設置為您的訂單,如下所示:

$order->setState('authorized', true, 'Status history message')
      ->save();

請讓我知道,如果你有任何問題。

因此需要在前面顯示狀態:

<config> <modules> <MyCompany_MyModule> <active>true</active> <codePool>local</codePool> <depends> <Mage_Sales/> </depends> </MyCompany_MyModule> </modules> </config>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM