通过Shipment Code找到Order信息

Shipment是EAV模型,默认不会选出order_id信息,因此需要使用使用addAttributeToSelect方法,代码如下:

$collection = Mage::getModel(‘sales/order_shipment’)->getCollection()->addAttributeToSelect(‘order_id’)->addAttributeToFilter(‘increment_id’, ‘100000002’);
foreach($collection AS $c) {
echo ‘Order Id : ‘ . $c->getOrder()->getId();
break;
}

标签