public function getItemByProductId($productId) { foreach ($this->_shipment->getItemsCollection() as $item) { if ($item->getProductId() == $productId) { return $item; } } return false; }
/** * Getter for billing address of order by format * * @param Mage_Sales_Model_Order_Shipment $shipment * @return array */ public function getShipmentItems($shipment) { $res = array(); foreach ($shipment->getItemsCollection() as $item) { if (!$item->getOrderItem()->getParentItem()) { $res[] = $item; } } return $res; }
/** * Returns OCL OrderLineData for Shipment record. This should only be used for shipment. * * @param Mage_Sales_Model_Order_Creditmemo $creditMemo * @return array */ protected function _createShipmentOrderLineData(Mage_Sales_Model_Order_Shipment $shipment) { $orderLineData = array(); $orderItemToShipmentItem = array(); foreach ($shipment->getItemsCollection() as $item) { $orderItemToShipmentItem[$item->getOrderItemId()] = $item; } /** @var $orderItem Mage_Sales_Model_Order_Item */ foreach ($this->_order->getItemsCollection() as $orderItem) { if (isset($orderItemToShipmentItem[$orderItem->getItemId()])) { $shipItem = $orderItemToShipmentItem[$orderItem->getItemId()]; $qtyShipped = $shipItem->getQty(); if ($qtyShipped > 0) { $lineData = $this->_createOrderLineData($orderItem); $lineData['quantity'] = $qtyShipped; // should not include tax according to contract $lineData['price'] = $this->_createCurrencyAmount($qtyShipped * $shipItem->getBasePrice()); // set total tax amount to 'null' because cannot guarantee the calculation of tax on a per unit basis // (e.g. no Magento functionality to calculate it) if ($orderItem->getQtyOrdered() != $qtyShipped) { $lineData['totalTaxAmount'] = null; } $orderLineData[] = $lineData; } } } return $orderLineData; }