public function testCreate()
 {
     $pricing = $this->dummyData->getPricing();
     $this->productQuantityDiscount->setCustomerGroup(null);
     $this->productQuantityDiscount->setQuantity(6);
     $this->productQuantityDiscount->setFlagApplyCatalogPromotions(true);
     $this->assertEntityValid($this->productQuantityDiscount);
     $this->assertSame(null, $this->productQuantityDiscount->getCustomerGroup());
     $this->assertSame(6, $this->productQuantityDiscount->getQuantity());
     $this->assertSame(true, $this->productQuantityDiscount->getFlagApplyCatalogPromotions());
     $this->assertSame($this->product, $this->productQuantityDiscount->getProduct());
     $this->assertTrue($this->productQuantityDiscount->getPrice($pricing) instanceof Price);
 }
 public function handle(CreateProductQuantityDiscountCommand $command)
 {
     $product = $this->productService->findOneById($command->getProductId());
     $productQuantityDiscount = new ProductQuantityDiscount($product, $command->getProductQuantityDiscountId());
     $productQuantityDiscount->setType(PromotionType::createById($command->getPromotionTypeId()));
     $productQuantityDiscount->setValue($command->getValue());
     $productQuantityDiscount->setReducesTaxSubtotal($command->getReducesTaxSubtotal());
     $productQuantityDiscount->setMaxRedemptions($command->getMaxRedemptions());
     $productQuantityDiscount->setStart($command->getStartDate());
     $productQuantityDiscount->setEnd($command->getEndDate());
     $productQuantityDiscount->setQuantity($command->getQuantity());
     $productQuantityDiscount->setFlagApplyCatalogPromotions($command->getFlagApplyCatalogPromotions());
     $this->productService->createProductQuantityDiscount($productQuantityDiscount);
 }
예제 #3
0
 public function getProductQuantityDiscount(Product $product = null)
 {
     if ($product === null) {
         $product = $this->getProduct();
     }
     $productQuantityDiscount = new ProductQuantityDiscount($product);
     $productQuantityDiscount->setType(PromotionType::percent());
     $productQuantityDiscount->setQuantity(6);
     $productQuantityDiscount->setValue(5);
     $productQuantityDiscount->setCustomerGroup(null);
     $productQuantityDiscount->setQuantity(1);
     $productQuantityDiscount->setFlagApplyCatalogPromotions(true);
     return $productQuantityDiscount;
 }