/**
  * {@inheritdoc}
  */
 public function setValue(array $products, AttributeInterface $attribute, $data, $locale = null, $scope = null)
 {
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'media');
     $this->checkData($attribute, $data);
     $file = $this->getFileData($attribute, $data);
     foreach ($products as $product) {
         $this->setMedia($attribute, $product, $file, $locale, $scope);
     }
     $this->mediaManager->handleAllProductsMedias($products);
 }
 /**
  * {@inheritdoc}
  */
 public function write(array $items)
 {
     $this->versionManager->setRealTimeVersioning($this->realTimeVersioning);
     foreach ($items as $item) {
         $this->incrementCount($item);
     }
     $this->mediaManager->handleAllProductsMedias($items);
     $this->productSaver->saveAll($items, ['recalculate' => false]);
     $this->detacher->detachAll($items);
 }
 /**
  * {@inheritdoc}
  */
 public function write(array $products)
 {
     $this->collection = $this->documentManager->getDocumentCollection($this->productClass);
     $productsToInsert = array();
     $productsToUpdate = array();
     foreach ($products as $product) {
         if (null === $product->getId()) {
             $productsToInsert[] = $product;
             $product->setId($this->mongoFactory->createMongoId());
         } else {
             $productsToUpdate[] = $product;
         }
     }
     $this->mediaManager->handleAllProductsMedias($products);
     $this->eventDispatcher->dispatch(self::PRE_INSERT, new GenericEvent($productsToInsert));
     $this->eventDispatcher->dispatch(self::PRE_UPDATE, new GenericEvent($productsToUpdate));
     $insertDocs = $this->getDocsFromProducts($productsToInsert);
     $updateDocs = $this->getDocsFromProducts($productsToUpdate);
     if (count($insertDocs) > 0) {
         $this->insertDocuments($insertDocs);
     }
     if (count($updateDocs) > 0) {
         $this->updateDocuments($updateDocs);
     }
     $this->pendingPersister->persistPendingVersions($products);
     $this->eventDispatcher->dispatch(self::POST_INSERT, new GenericEvent($productsToInsert));
     $this->eventDispatcher->dispatch(self::POST_UPDATE, new GenericEvent($productsToUpdate));
     $this->documentManager->clear();
     $this->cacheClearer->clear();
 }
 /**
  * @param ProductInterface[] $products
  *
  * @return null
  *
  * @deprecated will be removed in 1.4, replaced by MediaManager::handleAllProductsMedias
  */
 public function handleAllMedia(array $products)
 {
     return $this->mediaManager->handleAllProductsMedias($products);
 }