public function handle(CreateCatalogPromotionCommand $command) { $catalogPromotion = new CatalogPromotion($command->getCatalogPromotionId()); $catalogPromotion->setName($command->getName()); $catalogPromotion->setType(PromotionType::createById($command->getPromotionTypeId())); $catalogPromotion->setValue($command->getValue()); $catalogPromotion->setReducesTaxSubtotal($command->getReducesTaxSubtotal()); $catalogPromotion->setMaxRedemptions($command->getMaxRedemptions()); $catalogPromotion->setStart($command->getStartDate()); $catalogPromotion->setEnd($command->getEndDate()); if ($command->getTagId() !== null) { $tag = $this->tagService->findOneById($command->getTagId()); $catalogPromotion->setTag($tag); } $this->catalogPromotionService->create($catalogPromotion); }
public function testGetPriceWithCatalogPromotion() { $catalogPromotion = new CatalogPromotion(); $catalogPromotion->setName('20% Off'); $catalogPromotion->setType(PromotionType::percent()); $catalogPromotion->setValue(20); $this->pricing->setCatalogPromotions([$catalogPromotion]); $product = new Product(); $product->setUnitPrice(1500); $expectedPrice = new Price(); $expectedPrice->unitPrice = 1200; $expectedPrice->origUnitPrice = 1500; $expectedPrice->addCatalogPromotion($catalogPromotion); $expectedPrice->quantityPrice = 1200; $expectedPrice->origQuantityPrice = 1500; $this->assertEquals($expectedPrice, $this->pricingCalculator->getPrice($product, 1)); }
public function getCatalogPromotion() { $catalogPromotion = new CatalogPromotion(); $catalogPromotion->setName('Test Catalog Promotion'); $catalogPromotion->setCode('20PCTOFF'); $catalogPromotion->setValue(20); return $catalogPromotion; }