2014-08-28 55 views
0

我需要得到一个没有跟踪号码在magento中关联的货件的集合。零追踪号码出货magento的集合

$collection = Mage::getModel('sales/order_shipment')->getCollection(); 
$collection->addAttributeTofilter('track_number', ''); //not working 

请给我一个解决方案,如果你有。

+0

尝试'$收藏 - > addAttributeTofilter( '音轨',阵列( '空'=>真));' – Slimshadddyyy 2014-08-28 12:26:57

+0

谢谢,但我认为它不工作。我需要以某种方式加入跟踪货运模型吗? – Abhilash 2014-08-28 12:47:21

+0

我虽然已经有货物收集。 – Slimshadddyyy 2014-08-28 12:49:07

回答

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()); 
}