Exemplo n.º 1
0
 /**
  * @param \Magento\Catalog\Model\Product\Gallery\ReadHandler $mediaGalleryReadHandler
  * @param \Magento\Catalog\Model\Product $product
  * @return \Magento\Catalog\Model\Product
  */
 public function afterExecute(\Magento\Catalog\Model\Product\Gallery\ReadHandler $mediaGalleryReadHandler, \Magento\Catalog\Model\Product $product)
 {
     $mediaCollection = $this->getMediaEntriesDataCollection($product, $mediaGalleryReadHandler->getAttribute());
     if (!empty($mediaCollection)) {
         $ids = $this->collectVideoEntriesIds($mediaCollection);
         $videoDataCollection = $this->loadVideoDataById($ids, $product->getStoreId());
         $mediaEntriesDataCollection = $this->addVideoDataToMediaEntries($mediaCollection, $videoDataCollection);
         $product->setData($mediaGalleryReadHandler->getAttribute()->getAttributeCode(), $mediaEntriesDataCollection);
     }
     return $product;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getAttribute()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getAttribute');
     if (!$pluginInfo) {
         return parent::getAttribute();
     } else {
         return $this->___callPlugins('getAttribute', func_get_args(), $pluginInfo);
     }
 }
Exemplo n.º 3
0
 /**
  * Get all product images
  *
  * @param \Magento\Framework\DataObject $product
  * @param int $storeId
  * @return array
  */
 protected function _getAllProductImages($product, $storeId)
 {
     $product->setStoreId($storeId);
     $gallery = $this->mediaGalleryResourceModel->loadProductGalleryByAttributeId($product, $this->mediaGalleryReadHandler->getAttribute()->getId());
     $imagesCollection = [];
     if ($gallery) {
         $productMediaPath = $this->_getMediaConfig()->getBaseMediaUrlAddition();
         foreach ($gallery as $image) {
             $imagesCollection[] = new \Magento\Framework\DataObject(['url' => $productMediaPath . $image['file'], 'caption' => $image['label'] ? $image['label'] : $image['label_default']]);
         }
     }
     return $imagesCollection;
 }