示例#1
0
 /**
  * @param Mage_Sales_Model_Order $order
  * @return array
  */
 protected function _getOrderItemsFormatted($order)
 {
     $items = array();
     foreach ($order->getAllItems() as $item) {
         /** @var Mage_Sales_Model_Order_Item $item */
         // avoid child and parent products in list
         if (!$item->getParentItemId()) {
             $shopgateItem = new ShopgateExternalOrderItem();
             $shopgateItem->setItemNumber($item->getProductId());
             $shopgateItem->setItemNumberPublic($item->getSku());
             $shopgateItem->setQuantity((int) $item->getQtyOrdered());
             $shopgateItem->setname($item->getName());
             $shopgateItem->setUnitAmount($item->getPrice());
             $shopgateItem->setUnitAmountWithTax($item->getPriceInclTax());
             $shopgateItem->setTaxPercent($item->getTaxPercent());
             $shopgateItem->setCurrency($order->getOrderCurrencyCode());
             $shopgateItem->setDescription($item->getDescription());
             array_push($items, $shopgateItem);
         }
     }
     return $items;
 }
示例#2
0
 /**
  * @param OrderCore $order
  *
  * @return array
  */
 protected function _getOrderItems($order)
 {
     $result = array();
     if (method_exists($order, 'getOrderDetailList')) {
         $orderItems = $order->getOrderDetailList();
     } else {
         $orderItems = $order->getProducts();
     }
     foreach ($orderItems as $item) {
         /** @var OrderDetailCore $orderItemCore */
         $orderItemCore = new OrderDetail($item['id_order_detail']);
         $orderItem = new ShopgateExternalOrderItem();
         $orderItem->setItemNumber($orderItemCore->product_id);
         //$orderItem->setItemNumberPublic()
         $orderItem->setQuantity($orderItemCore->product_quantity);
         $orderItem->setName($orderItemCore->product_name);
         $orderItem->setUnitAmount($orderItemCore->unit_price_tax_excl);
         $orderItem->setUnitAmountWithTax($orderItemCore->unit_price_tax_incl);
         $orderItem->setTaxPercent($orderItemCore->tax_rate);
         /** @var CurrencyCore $currency */
         $currency = Currency::getCurrency($order->id_currency);
         $orderItem->setCurrency($currency['iso_code']);
         if (!array_key_exists($orderItemCore->tax_rate, $this->_orderTaxes)) {
             $this->_orderTaxes[$orderItemCore->tax_rate] = array('tax_name' => $orderItemCore->tax_name, 'price_tax_excl' => $orderItemCore->unit_price_tax_excl * $orderItemCore->product_quantity);
         } else {
             $taxInfoItem = $this->_orderTaxes[$orderItemCore->tax_rate];
             $taxInfoItem['price_tax_excl'] = $taxInfoItem['price_tax_excl'] + $orderItemCore->unit_price_tax_excl * $orderItemCore->product_quantity;
             $this->_orderTaxes[$orderItemCore->tax_rate] = $taxInfoItem;
         }
         $result[] = $orderItem;
     }
     return $result;
 }