Exemple #1
0
 /**
  * @depends testVariantImageReset
  * @param $variantId
  */
 public function testVariantAddImage($variantId)
 {
     $this->resource->setResultMode(\Shopware\Components\Api\Resource\Variant::HYDRATE_OBJECT);
     $variant = $this->resource->getOne($variantId);
     $this->assertTrue($variant->getImages()->count() === 0);
     $update = array('articleId' => $variant->getArticle()->getId(), 'images' => $this->getSimpleMedia(3));
     $variant = $this->resource->update($variantId, $update);
     $this->assertCount(3, $variant->getImages());
     $add = array('articleId' => $variant->getArticle()->getId(), '__options_images' => array('replace' => false), 'images' => $this->getSimpleMedia(5, 20));
     $variant = $this->resource->update($variantId, $add);
     $this->assertCount(8, $variant->getImages());
     /**@var $image \Shopware\Models\Article\Image*/
     foreach ($variant->getArticle()->getImages() as $image) {
         $this->assertCount(1, $image->getMappings(), "No image mapping created!");
         /**@var $mapping \Shopware\Models\Article\Image\Mapping*/
         $mapping = $image->getMappings()->current();
         $this->assertCount($variant->getConfiguratorOptions()->count(), $mapping->getRules(), "Image mapping contains not enough rules. ");
     }
 }
Exemple #2
-1
 public function updateConfiguratorVariants($articleId, $data)
 {
     foreach ($data as $updateInformation) {
         $options = $updateInformation['options'];
         $variantData = $updateInformation['data'];
         $variants = $this->getVariantsByOptions($articleId, $options);
         if (empty($variants)) {
             continue;
         }
         foreach ($variants as $variantId) {
             $this->variantApi->update($variantId, $variantData);
         }
     }
 }