我正在尝试为 Magento 构建一个获取发票编号的模块。主要问题是我收到一个致命错误:调用非对象上的成员函数 getIncrementId()...在第 19 行($invoice 创建行)。我的功能是:
$invoice = $observer->getEvent()->getInvoice()->getIncrementId();
$last4 = substr($invoice, -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);