diff --git a/Helper/ProductGalleryHelper.php b/Helper/ProductGalleryHelper.php index 934a06d..66d5209 100644 --- a/Helper/ProductGalleryHelper.php +++ b/Helper/ProductGalleryHelper.php @@ -60,7 +60,7 @@ public function __construct( * @method getCloudinaryPGOptions * @param bool $refresh Refresh options * @param bool $ignoreDisabled Get te options even if the module or the product gallery are disabled - * @return array + * @return array|null */ public function getCloudinaryPGOptions($refresh = false, $ignoreDisabled = false) { diff --git a/Model/Api/ProductGalleryManagement.php b/Model/Api/ProductGalleryManagement.php index 9b1c195..cc42dd6 100644 --- a/Model/Api/ProductGalleryManagement.php +++ b/Model/Api/ProductGalleryManagement.php @@ -10,6 +10,7 @@ use Cloudinary\Cloudinary\Model\ProductGalleryApiQueueFactory; use Cloudinary\Cloudinary\Model\ProductImageFinder; use Cloudinary\Cloudinary\Model\TransformationFactory; +use Cloudinary\Cloudinary\Helper\ProductGalleryHelper; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Product\Gallery\Processor; use Magento\Catalog\Model\Product\Media\Config as ProductMediaConfig; @@ -161,6 +162,8 @@ class ProductGalleryManagement implements \Cloudinary\Cloudinary\Api\ProductGall */ private $resourceConnection; + private $productGalleryHelper; + /** * @method __construct * @param ConfigurationInterface $configuration @@ -208,7 +211,8 @@ public function __construct( MediaLibraryMapFactory $mediaLibraryMapFactory, ProductGalleryApiQueueFactory $productGalleryApiQueueFactory, AppEmulation $appEmulation, - ResourceConnection $resourceConnection + ResourceConnection $resourceConnection, + ProductGalleryHelper $productGalleryHelper ) { $this->configuration = $configuration; $this->request = $request; @@ -232,6 +236,7 @@ public function __construct( $this->productGalleryApiQueueFactory = $productGalleryApiQueueFactory; $this->appEmulation = $appEmulation; $this->resourceConnection = $resourceConnection; + $this->productGalleryHelper = $productGalleryHelper; } @@ -405,6 +410,7 @@ private function _getProductMedia($sku) } return $this->jsonHelper->jsonEncode($result); + } /** @@ -828,6 +834,7 @@ private function getProductCldUrlsBySku($sku) 'small_image' => null, 'thumbnail' => null, 'media_gallery' => [], + 'gallery_widget_parameters' => [], ]; try { $product = $this->productRepository->get($sku); @@ -843,6 +850,7 @@ private function getProductCldUrlsBySku($sku) $urls['thumbnail'] = $gallItem->getUrl(); } } + $urls['gallery_widget_parameters'] = $this->jsonHelper->jsonEncode($this->productGalleryHelper->getCloudinaryPGOptions()); } catch (\Exception $e) { $urls = [ 'error' => 1, diff --git a/etc/schema.graphqls b/etc/schema.graphqls index 8d2e385..1c07162 100644 --- a/etc/schema.graphqls +++ b/etc/schema.graphqls @@ -3,10 +3,11 @@ type CloudinaryData { small_image: String thumbnail: String media_gallery: [String] + gallery_widget_parameters: String @doc(description: "Cloudinary gallery widget parameters (json)") } interface ProductInterface { cld_data: CloudinaryData @resolver(class: "\\Cloudinary\\Cloudinary\\Model\\GraphQLResolver\\ProductAttributeCldResolver") - @doc(description: "Cloudinary urls generated for product images") -} \ No newline at end of file + @doc(description: "Cloudinary urls generated for product images and gallery widget parameters.") +}