我需要收集一些没有与magento关联的跟踪号的货件。
$collection = Mage::getModel('sales/order_shipment')->getCollection();
$collection->addAttributeTofilter('track_number', ''); //not working
如果你有,请给我一个解决方案。
答案 0 :(得分:0)
我需要相同的功能,并设法使用以下代码(magento 1.9.3):
$collection = Mage::getModel('sales/order_shipment')->getCollection()
->addAttributeTofilter('track_number', array('null' => true));
$trackTableName = Mage::getSingleton('core/resource')->getTableName('sales/shipment_track');
$collection->getSelect()->joinLeft(
array('tracking' => $trackTableName), 'main_table.order_id=tracking.order_id',
array()
);
foreach ($collection as $shipment) {
print_r($shipment->getData());
}