Skip to content

Commit 08b02c5

Browse files
2 parents 0114124 + 9a0c79f commit 08b02c5

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Helper/ProductGalleryHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(
6060
* @method getCloudinaryPGOptions
6161
* @param bool $refresh Refresh options
6262
* @param bool $ignoreDisabled Get te options even if the module or the product gallery are disabled
63-
* @return array
63+
* @return array|null
6464
*/
6565
public function getCloudinaryPGOptions($refresh = false, $ignoreDisabled = false)
6666
{

Model/Api/ProductGalleryManagement.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Cloudinary\Cloudinary\Model\ProductGalleryApiQueueFactory;
1111
use Cloudinary\Cloudinary\Model\ProductImageFinder;
1212
use Cloudinary\Cloudinary\Model\TransformationFactory;
13+
use Cloudinary\Cloudinary\Helper\ProductGalleryHelper;
1314
use Magento\Catalog\Api\ProductRepositoryInterface;
1415
use Magento\Catalog\Model\Product\Gallery\Processor;
1516
use Magento\Catalog\Model\Product\Media\Config as ProductMediaConfig;
@@ -161,6 +162,8 @@ class ProductGalleryManagement implements \Cloudinary\Cloudinary\Api\ProductGall
161162
*/
162163
private $resourceConnection;
163164

165+
private $productGalleryHelper;
166+
164167
/**
165168
* @method __construct
166169
* @param ConfigurationInterface $configuration
@@ -208,7 +211,8 @@ public function __construct(
208211
MediaLibraryMapFactory $mediaLibraryMapFactory,
209212
ProductGalleryApiQueueFactory $productGalleryApiQueueFactory,
210213
AppEmulation $appEmulation,
211-
ResourceConnection $resourceConnection
214+
ResourceConnection $resourceConnection,
215+
ProductGalleryHelper $productGalleryHelper
212216
) {
213217
$this->configuration = $configuration;
214218
$this->request = $request;
@@ -232,6 +236,7 @@ public function __construct(
232236
$this->productGalleryApiQueueFactory = $productGalleryApiQueueFactory;
233237
$this->appEmulation = $appEmulation;
234238
$this->resourceConnection = $resourceConnection;
239+
$this->productGalleryHelper = $productGalleryHelper;
235240
}
236241

237242

@@ -405,6 +410,7 @@ private function _getProductMedia($sku)
405410
}
406411

407412
return $this->jsonHelper->jsonEncode($result);
413+
408414
}
409415

410416
/**
@@ -828,6 +834,7 @@ private function getProductCldUrlsBySku($sku)
828834
'small_image' => null,
829835
'thumbnail' => null,
830836
'media_gallery' => [],
837+
'gallery_widget_parameters' => [],
831838
];
832839
try {
833840
$product = $this->productRepository->get($sku);
@@ -843,6 +850,7 @@ private function getProductCldUrlsBySku($sku)
843850
$urls['thumbnail'] = $gallItem->getUrl();
844851
}
845852
}
853+
$urls['gallery_widget_parameters'] = $this->jsonHelper->jsonEncode($this->productGalleryHelper->getCloudinaryPGOptions());
846854
} catch (\Exception $e) {
847855
$urls = [
848856
'error' => 1,

etc/schema.graphqls

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ type CloudinaryData {
33
small_image: String
44
thumbnail: String
55
media_gallery: [String]
6+
gallery_widget_parameters: String @doc(description: "Cloudinary gallery widget parameters (json)")
67
}
78

89
interface ProductInterface {
910
cld_data: CloudinaryData
1011
@resolver(class: "\\Cloudinary\\Cloudinary\\Model\\GraphQLResolver\\ProductAttributeCldResolver")
11-
@doc(description: "Cloudinary urls generated for product images")
12-
}
12+
@doc(description: "Cloudinary urls generated for product images and gallery widget parameters.")
13+
}

0 commit comments

Comments
 (0)