public function __construct(OrderItem $orderItem, DTOBuilderFactoryInterface $dtoBuilderFactory)
 {
     $this->entity = $orderItem;
     $this->dtoBuilderFactory = $dtoBuilderFactory;
     $this->entityDTO = $this->getEntityDTO();
     $this->setId();
     $this->setTime();
     $this->entityDTO->quantity = $this->entity->getQuantity();
     $this->entityDTO->sku = $this->entity->getSku();
     $this->entityDTO->name = $this->entity->getName();
     $this->entityDTO->discountNames = $this->entity->getDiscountNames();
     $this->entityDTO->areAttachmentsEnabled = $this->entity->areAttachmentsEnabled();
     if ($this->entity->getPrice() !== null) {
         $this->entityDTO->price = $this->dtoBuilderFactory->getPriceDTOBuilder($orderItem->getPrice())->withAllData()->build();
     }
     if ($this->entity->getProduct() !== null) {
         $this->entityDTO->shippingWeight = $this->entity->getShippingWeight();
         $this->entityDTO->quantityShippingWeight = $this->entity->getQuantityShippingWeight();
         $this->entityDTO->product = $this->dtoBuilderFactory->getProductDTOBuilder($this->entity->getProduct())->withTags()->build();
     }
 }
Esempio n. 2
0
 public function testGetQuantityShippingWeight()
 {
     $product1 = $this->dummyData->getProduct();
     $product1->setShippingWeight(1);
     $order = $this->dummyData->getOrder();
     $orderItem = new OrderItem($order);
     $orderItem->setProduct($product1);
     $orderItem->setQuantity(2);
     $this->assertSame(1, $orderItem->getShippingWeight());
     $this->assertSame(2, $orderItem->getQuantityShippingWeight());
     $product2 = $this->dummyData->getProduct();
     $product2->setShippingWeight(3);
     $optionProduct = $this->dummyData->getOptionProduct(null, $product2);
     $orderItemOptionProduct = $this->dummyData->getOrderItemOptionProduct($optionProduct);
     $orderItem->addOrderItemOptionProduct($orderItemOptionProduct);
     $orderItem->addOrderItemOptionProduct($orderItemOptionProduct);
     $this->assertSame(14, $orderItem->getQuantityShippingWeight());
     $optionValue = $this->dummyData->getOptionValue();
     $optionValue->setShippingWeight(5);
     $orderItemOptionValue = $this->dummyData->getOrderItemOptionValue($optionValue);
     $orderItem->addOrderItemOptionValue($orderItemOptionValue);
     $orderItem->addOrderItemOptionValue($orderItemOptionValue);
     $this->assertSame(17, $orderItem->getShippingWeight());
     $this->assertSame(34, $orderItem->getQuantityShippingWeight());
 }