Last updated: Jan-16-2025
With the Cloudinary module for Magento (Adobe Commerce), you can use GraphQL to retrieve Cloudinary URLs for all media image attributes associated with your products. This guide explains how to query custom media attributes and Product Gallery Widget parameters using GraphQL.
Magento product data and Cloudinary integration
In Magento, product information consists of various attributes, including custom attributes defined by users, such as media image attributes. The custom_media_attributes
field, combined with the attribute_codes
argument, enables retrieving Cloudinary URLs for any media image attribute, including custom-defined ones. For more details on Magento product attributes, refer to the official Magento documentation. To learn more about attribute input types, explore the Attribute Input Types documentation.
Query overview
The GraphQL query retrieves Cloudinary-specific product data for a product with a specific SKU. This includes:
-
custom_media_attributes
: URLs for Cloudinary image delivery, linked to specified attribute codes. -
gallery_widget_parameters
: Configuration settings for the Product Gallery Widget.
These fields are nested under the cld_data
field within the products
query.
Query for custom media attributes
To retrieve Cloudinary URLs for specific media image attributes, use the custom_media_attributes
field with the attribute_codes
argument. Here’s an example query for a product with SKU "WS12":
Query breakdown
Your request includes the following parameters:
-
products
: The main query field to fetch products. -
filter
: Specifies the criteria for fetching products. -
sku: { eq: "WS12" }
: Filters the product by SKU "WS12". -
items
: Represents the list of products matching the specified filter criteria. -
cld_data
: A nested field that contains Cloudinary-specific product data. -
custom_media_attributes
: Accepts theattribute_codes
argument to specify media attribute codes. -
attribute_code
: The code for a media image attribute. -
url
: The Cloudinary URL associated with the attribute.
Sample response
Query for Product Gallery Widget parameters
To fetch Product Gallery Widget settings for a specific SKU, use the gallery_widget_parameters
field:
Query breakdown
Your request includes the following parameters:
-
products
: The main query field to fetch products. -
filter
: Specifies the criteria for fetching the product.-
sku: { eq: "WS12" }
: Filters the product by the SKU.
-
-
items
: Represents the list of products matching the specified filter criteria. -
cld_data
: Contains Cloudinary-specific data for each product.-
gallery_widget_parameters
: Returns a JSON string with the Product Gallery Widget configuration.
-