2013-04-29 90 views

回答

2

當您創建貨件時,請使用自定義模塊的觀察者動態分配跟蹤編號。見下文。

config.xml中

<sales_order_shipment_save_before> 
    <observers> 
     <namespace_modulename_ship_before> 
      <type>singleton</type> 
      <class>Namespace_Modulename_Model_Observer</class> 
      <method>salesOrderShipmentSaveBefore</method> 
     </namespace_modulename_ship_before> 
    </observers> 
</sales_order_shipment_save_before> 

Observer.php

public function salesOrderShipmentSaveBefore($observer) 
{ 
    $invoice = $observer->getEvent()->getInvoice(); 
    $last4 = substr($invoice->getIncrementId(), -4); 

    $shipment = $observer->getEvent()->getShipment(); 
    $track = Mage::getModel('sales/order_shipment_track') 
       ->setNumber($last4) //tracking number/awb number 
       ->setCarrierCode('custom') //carrier code 
       ->setTitle('Custom'); //carrier title 
    $shipment->addTrack($track); 
} 

信用:http://ka.lpe.sh/2012/01/08/magento-save-shipment-information-tracking-number-carrier-code-programatically/

+0

你能或許能給我如何創建模塊鏈接:|仍然需要在那裏工作 – HWR 2013-04-29 12:18:17

+0

在這裏你將需要3個文件..一個在應用程序/ etc/modules /用於註冊你的自定義模塊,第二個在你的本地/命名空間/模塊/ etc/ie config.xml我寫上面,第三個本地/命名空間/模塊/模型/您的觀察員我寫上面..鏈接學習創建模塊http://stackoverflow.com/questions/576908/how-to-create-a-simple-hello-world-module-in- Magento的 – Kalpesh 2013-04-29 13:09:08

相關問題