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;
}
出處:http://koda.javaeye.com/blog/639987