public function matches(CartItem $cartItem)
 {
     foreach ($cartItem->getProduct()->getTags() as $tag) {
         if ($tag->getId() === $this->tag->getId() and $cartItem->getQuantity() >= $this->quantity) {
             return true;
         }
     }
     return false;
 }
Пример #2
0
 public function isTagValid(Product $product)
 {
     if ($this->tag === null) {
         return true;
     }
     foreach ($product->getTags() as $tag) {
         if ($tag->getId() !== null and $tag->getId() == $this->tag->getId()) {
             return true;
         }
     }
     return false;
 }
Пример #3
0
 /**
  * @return static
  */
 public function withTextOptions()
 {
     foreach ($this->entity->getTextOptions() as $textOption) {
         $this->entityDTO->textOptions[] = $this->dtoBuilderFactory->getTextOptionDTOBuilder($textOption)->build();
     }
     return $this;
 }
Пример #4
0
 public function testRemoveImage()
 {
     $image1 = $this->dummyData->getImage();
     $image2 = $this->dummyData->getImage();
     $tag = new Tag();
     $tag->addImage($image1);
     $tag->addImage($image2);
     $this->assertSame(2, count($tag->getImages()));
     $tag->removeImage($image2);
     $this->assertSame(1, count($tag->getImages()));
 }
 public function testGetRelatedProducts()
 {
     $product1 = $this->dummyData->getProduct();
     $product2 = $this->dummyData->getProduct();
     $product3 = $this->dummyData->getProduct();
     $tag = new Tag();
     $tag->setName('Test Tag');
     $tag->setIsVisible(true);
     $product1->addTag($tag);
     $product2->addTag($tag);
     $this->entityManager->persist($tag);
     $this->entityManager->persist($product1);
     $this->entityManager->persist($product2);
     $this->entityManager->persist($product3);
     $this->entityManager->flush();
     $this->entityManager->clear();
     $products = $this->productRepository->getRelatedProductsByIds([$product1->getId()]);
     $this->assertSame(1, count($products));
     $this->assertEntitiesEqual($product2, $products[0]);
 }
Пример #6
0
 public function getTag()
 {
     $tag = new Tag();
     $tag->setName('Test Tag');
     $tag->setCode('TT' . uniqid());
     $tag->setDescription('Test Description');
     $tag->setDefaultImage('http://lorempixel.com/400/200/');
     $tag->setSortOrder(0);
     $tag->setIsActive(true);
     $tag->setIsVisible(true);
     return $tag;
 }