Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronen-Michaeli-22 committed Jul 10, 2024
2 parents 0114124 + 9a0c79f commit 08b02c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Helper/ProductGalleryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 9 additions & 1 deletion Model/Api/ProductGalleryManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -161,6 +162,8 @@ class ProductGalleryManagement implements \Cloudinary\Cloudinary\Api\ProductGall
*/
private $resourceConnection;

private $productGalleryHelper;

/**
* @method __construct
* @param ConfigurationInterface $configuration
Expand Down Expand Up @@ -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;
Expand All @@ -232,6 +236,7 @@ public function __construct(
$this->productGalleryApiQueueFactory = $productGalleryApiQueueFactory;
$this->appEmulation = $appEmulation;
$this->resourceConnection = $resourceConnection;
$this->productGalleryHelper = $productGalleryHelper;
}


Expand Down Expand Up @@ -405,6 +410,7 @@ private function _getProductMedia($sku)
}

return $this->jsonHelper->jsonEncode($result);

}

/**
Expand Down Expand Up @@ -828,6 +834,7 @@ private function getProductCldUrlsBySku($sku)
'small_image' => null,
'thumbnail' => null,
'media_gallery' => [],
'gallery_widget_parameters' => [],
];
try {
$product = $this->productRepository->get($sku);
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
@doc(description: "Cloudinary urls generated for product images and gallery widget parameters.")
}

0 comments on commit 08b02c5

Please sign in to comment.