예제 #1
0
 protected function createBaseOrderItem(Order $order)
 {
     $orderItem = new OrderItem();
     $orderItem->setId(mt_rand(0, 9999));
     $orderItem->setName('some order item');
     $orderItem->setSku('some sku');
     $orderItem->setQty(1);
     $orderItem->setOrder($order);
     $orderItem->setCost(51.0);
     $orderItem->setPrice(75.0);
     $orderItem->setWeight(6.12);
     $orderItem->setTaxPercent(2);
     $orderItem->setTaxAmount(1.5);
     $orderItem->setDiscountPercent(4);
     $orderItem->setDiscountAmount(0);
     $orderItem->setRowTotal(234);
     $this->em->persist($orderItem);
     return $orderItem;
 }
예제 #2
0
 /**
  * @param ObjectManager $om
  * @param Order         $order
  * @param Cart          $cart
  *
  * @return OrderItem[]
  */
 protected function generateOrderItem(ObjectManager $om, Order $order, Cart $cart)
 {
     $cartItems = $cart->getCartItems();
     $orderItems = array();
     foreach ($cartItems as $cartItem) {
         $orderItem = new OrderItem();
         $orderItem->setOriginId($cartItem->getOriginId());
         $orderItem->setOrder($order);
         $orderItem->setTaxAmount($cartItem->getTaxAmount());
         $orderItem->setTaxPercent($cartItem->getTaxPercent());
         $orderItem->setRowTotal($cartItem->getRowTotal());
         $orderItem->setProductType($cartItem->getProductType());
         $orderItem->setIsVirtual((bool) $cartItem->getIsVirtual());
         $orderItem->setQty($cartItem->getQty());
         $orderItem->setSku($cartItem->getSku());
         $orderItem->setPrice($cartItem->getPrice());
         $orderItem->setOriginalPrice($cartItem->getPrice());
         $orderItem->setName($cartItem->getName());
         $orderItems[] = $orderItem;
         $om->persist($orderItem);
     }
     $order->setItems($orderItems);
     $om->persist($order);
     return $orderItems;
 }