public function handle(GetRandomProductsQuery $query)
 {
     $products = $this->productService->getRandomProducts($query->getRequest()->getLimit());
     foreach ($products as $product) {
         $query->getResponse()->addProductDTOBuilder($this->dtoBuilderFactory->getProductDTOBuilder($product));
     }
 }
Ejemplo n.º 2
0
 public function handle(UpdateProductCommand $command)
 {
     $productDTO = $command->getProductDTO();
     $product = $this->productService->findOneById($productDTO->id);
     ProductDTOBuilder::setFromDTO($product, $productDTO);
     $this->productService->update($product);
 }
 public function handle(CreateOptionProductCommand $command)
 {
     $option = $this->optionService->findOneById($command->getOptionId());
     $product = $this->productService->findOneById($command->getProductId());
     $optionProduct = OptionProductDTOBuilder::createFromDTO($option, $product, $command->getOptionProductDTO());
     $this->optionService->createOptionProduct($optionProduct);
 }
 public function handle(SetDefaultImageForProductCommand $command)
 {
     $product = $this->productService->findOneById($command->getProductId());
     $image = $this->imageService->findOneById($command->getImageId());
     $product->setDefaultImage($image->getPath());
     $this->productService->update($product);
 }
Ejemplo n.º 5
0
 /**
  * @param UploadFileDTO $uploadFileDTO
  * @param UuidInterface $userId
  * @param UuidInterface $productId
  * @return void
  */
 public function createAttachmentForUserProduct(UploadFileDTO $uploadFileDTO, UuidInterface $userId, UuidInterface $productId)
 {
     $user = $this->userService->findOneById($userId);
     $product = $this->productService->findOneById($productId);
     $attachment = $this->createAttachment($uploadFileDTO);
     $userProductAttachment = new UserProductAttachment($user, $product, $attachment);
     $this->attachmentRepository->create($userProductAttachment);
 }
 public function handle(GetProductsByTagQuery $query)
 {
     $paginationDTO = $query->getRequest()->getPaginationDTO();
     $pagination = new Pagination($paginationDTO->maxResults, $paginationDTO->page);
     $products = $this->productService->getProductsByTagId($query->getRequest()->getTagId(), $pagination);
     $query->getResponse()->setPaginationDTOBuilder($this->dtoBuilderFactory->getPaginationDTOBuilder($pagination));
     foreach ($products as $product) {
         $query->getResponse()->addProductDTOBuilder($this->dtoBuilderFactory->getProductDTOBuilder($product));
     }
 }
Ejemplo n.º 7
0
 public function handle(ListProductsQuery $query)
 {
     $paginationDTO = $query->getRequest()->getPaginationDTO();
     $pagination = new Pagination($paginationDTO->maxResults, $paginationDTO->page);
     $tags = $this->tagService->getAllProducts($query->getRequest()->getQueryString(), $pagination);
     $query->getResponse()->setPaginationDTOBuilder($this->dtoBuilderFactory->getPaginationDTOBuilder($pagination));
     foreach ($tags as $tag) {
         $query->getResponse()->addProductDTOBuilder($this->dtoBuilderFactory->getProductDTOBuilder($tag));
     }
 }
 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);
 }
 public function handle(RemoveTagFromProductCommand $command)
 {
     $this->productService->removeTag($command->getProductId(), $command->getTagId());
 }
 public function handle(AdjustInventoryCommand $command)
 {
     $product = $this->productService->findOneById($command->getProductId());
     $this->inventoryService->adjustInventory($product, $command->getQuantity(), $command->getInventoryLocationId(), InventoryTransactionType::createById($command->getTransactionTypeId()));
 }
 public function handle(RemoveImageFromProductCommand $command)
 {
     $this->productService->removeImage($command->getProductId(), $command->getImageId());
 }
Ejemplo n.º 12
0
 public function handle(GetProductQuery $query)
 {
     $product = $this->productService->findOneById($query->getRequest()->getProductId());
     $query->getResponse()->setProductDTOBuilder($this->dtoBuilderFactory->getProductDTOBuilder($product));
 }
Ejemplo n.º 13
0
 public function handle(DeleteProductCommand $command)
 {
     $product = $this->productService->findOneById($command->getProductId());
     $this->productService->delete($product);
 }
Ejemplo n.º 14
0
 public function handle(CreateProductCommand $command)
 {
     $product = ProductDTOBuilder::createFromDTO($command->getProductId(), $command->getProductDTO());
     $this->productService->create($product);
 }
 public function handle(UnsetDefaultImageForProductCommand $command)
 {
     $product = $this->productService->findOneById($command->getProductId());
     $product->setDefaultImage(null);
     $this->productService->update($product);
 }
 public function handle(AddTagToProductCommand $command)
 {
     $this->productService->addTag($command->getProductId(), $command->getTagId());
 }