### Run REPL (Clojure)
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/reporting/import-api.md
Starts a Clojure REPL, requires the users table example namespace, and runs the example.
```Clojure
lein repl
> (ns examples.users-table)
> (require :reload 'examples.users-table)
> (run)
```
--------------------------------
### Quick Start: Subscribe, Set Context, Publish, Unsubscribe
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/shared-services/storefront-events/sdk/install.md
This example demonstrates the basic usage of the Storefront Events SDK after it has been imported. It shows how to subscribe to page view events, set page context data, publish a page view event, and unsubscribe from events. Ensure relevant context data is populated before publishing events that require it.
```javascript
import mse from "@adobe/magento-storefront-events-sdk";
// subscribe to events
mse.subscribe.pageView(pageViewHandler);
// set context data
mse.context.setPage(/* page context */);
// publish events
mse.publish.pageView();
// unsubscribe from events
mse.unsubscribe.pageView(pageViewHandler);
```
--------------------------------
### Install SDK via NPM
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/product-recommendations/index.md
Install the Product Recommendations SDK as a module from NPM.
```bash
npm install @magento/recommendations-js-sdk
```
--------------------------------
### ProductViewInputOption Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example of a ProductViewInputOption object, detailing its fields and their types.
```json
{
"id": "4",
"title": "xyz789",
"required": false,
"type": "abc123",
"markupAmount": 987.65,
"suffix": "xyz789",
"sortOrder": 987,
"range": ProductViewInputOptionRange,
"imageSize": ProductViewInputOptionImageSize,
"fileExtensions": "abc123"
}
```
--------------------------------
### ProductViewInputOptionImageSize Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example of a ProductViewInputOptionImageSize object, specifying image dimensions.
```json
{"width": 987, "height": 987}
```
--------------------------------
### Copy Environment Example File
Source: https://github.com/adobedocs/commerce-services/blob/main/README.md
Before building the API reference, copy the example environment file to create your own configuration.
```bash
cp .env.example .env
```
--------------------------------
### ProductViewMoney Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example of a ProductViewMoney object, representing a monetary value with currency.
```json
{"currency": "AED", "value": 987.65}
```
--------------------------------
### Example Fetched Recommendations Data
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/product-recommendations/index.md
This is an example of the JSON data structure returned by the `client.fetch()` method, representing product recommendations. The example is intentionally truncated.
```json
{
"units": [
{
"unitId": "45687",
"unitName": "test-recs",
"searchTime": 10,
"totalResults": 3,
"results": [
{
"rank": 1,
"score": 0.38299224,
"sku": "35123",
"name": "Pursuit Lumaflex™ Tone Band",
"shortDescription": null,
"type": "simple",
"categories": [
"gear",
"gear/fitness-equipment"
],
"weight": 0.0,
"weightType": null,
"currency": "USD",
"image": {
"label": "",
"url": "http://magento2sc.local/pub/media/catalog/product/cache/fbb00452bcc1f45faf89264b683c708f/u/g/ug02-bk-0.jpg"
},
"smallImage": {
"label": "",
"url": "http://magento2sc.local/pub/media/catalog/product/cache/fbb00452bcc1f45faf89264b683c708f/u/g/ug02-bk-0.jpg"
},
"thumbnailImage": null,
"swatchImage": null,
"parents": [],
"url": "http://magento2sc.local/pursuit-lumaflex-trade-tone-band.html",
"prices": {
"maximum": {
"finalAdjustments": [],
"final": 16.0,
"regular": 16.0,
"regularAdjustments": []
},
"minimum": {
"finalAdjustments": [],
"final": 16.0,
"regular": 16.0,
"regularAdjustments": []
}
}
}
```
--------------------------------
### ProductViewLink Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example of a ProductViewLink object, used for related products and cross-selling.
```json
{
"product": ProductView,
"linkTypes": ["abc123"]
}
```
--------------------------------
### Complete SDK Workflow Example
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/product-recommendations/index.md
This example demonstrates the full lifecycle of using the Recommendations SDK, from importing the client and registering a recommendation unit to fetching data, rendering it with a template, and inserting it into the DOM.
```javascript
import RecommendationsClient from "@magento/recommendations-js-sdk"
// create the client
const client = new RecommendationsClient()
// register pre-built recommendation unit
client.register({
name: "Most Viewed Products",
type: "most-viewed",
})
// retrieve recommendations for all units
const {status, data} = await client.fetch()
// render the markup
const markup = client.render({
unit: data.units[0],
})
// insert the markup
document.body.insertAdjacentHTML("beforeend", markup)
```
--------------------------------
### Install SDK via npm
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/shared-services/storefront-events/sdk/install.md
Run this command to install the SDK as a dependency in your JavaScript project. This is for using the bundled version of the SDK.
```bash
npm install @adobe/magento-storefront-events-sdk
```
--------------------------------
### ProductViewInputOptionRange Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example of a ProductViewInputOptionRange object, defining the value range for an input option.
```json
{"from": 123.45, "to": 987.65}
```
--------------------------------
### Price Type Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example structure for product pricing, including adjustments and monetary amount.
```json
{
"adjustments": [PriceAdjustment],
"amount": ProductViewMoney
}
```
--------------------------------
### Install Dependencies (PHP)
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/reporting/import-api.md
Installs project dependencies using Composer and runs the users table script.
```Bash
composer install
php users-table.php
```
--------------------------------
### Install Dependencies (JavaScript)
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/reporting/import-api.md
Installs project dependencies using npm and runs the users table script.
```Bash
npm install
node users-table.js
```
--------------------------------
### Install Dependencies (Ruby)
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/reporting/import-api.md
Installs project dependencies using Bundler and runs the users table script.
```Bash
bundle install
ruby users-table.rb
```
--------------------------------
### Install Dependencies (Python)
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/reporting/import-api.md
Installs project dependencies using pip and runs the users table script.
```Bash
pip install
python examples/users_table.py
```
--------------------------------
### Install Project Dependencies with Yarn
Source: https://github.com/adobedocs/commerce-services/blob/main/README.md
Use this command to install all necessary project dependencies when setting up the local development environment.
```bash
yarn install
```
--------------------------------
### GraphQL Product Search Response Example
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/optimizer/ccdm-use-case.md
This is an example response from the `productSearch` GraphQL query, showing the details of a retrieved SKU, including its name, images, attributes, and pricing.
```json
{
"errors": [],
"data": {
"productSearch": {
"items": [
{
"productView": {
"sku": "aurora_prism_battery",
"name": "Aurora Prism battery",
"images": [
{
"url": "https://picsum.photos/300/200",
"label": "aurora prism battery photo",
"roles": [
"PDP",
"PLP"
]
}
],
"links": [
{
"sku": "aurora-prism-2025",
"type": "related"
}
],
"attributes": [
{
"code": "Brand",
"type": "STRING",
"values": [
"Aurora"
]
},
{
"code": "country",
"type": "ARRAY",
"values": [
"USA"
]
}
],
"description": "Zenith Automotive Vehicles and Parts",
"shortDescription": "battery",
"routes": [
{
"path": "aurora-prism-battery"
},
{
"path": "vehicles/aurora-prism/parts",
"position": 1
}
],
"roles": [
"SEARCH",
"CATALOG"
],
"metaTags": {
"title": " ",
"description": "Zenith Automotive Vehicles and Parts",
"keywords": [
"battery",
"part"
]
},
"price": {
"final": {
"amount": {
"value": "2099.00",
"currency": "USD"
}
},
"regular": {
"amount": {
"value": "2299.00",
"currency": "USD"
}
}
}
}
}
]
}
}
}
```
--------------------------------
### Action Request Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/admin-api/index.html
An example of the ActionRequest input object, used for defining actions within a policy.
```json
{
"filters": [ActionFilterRequest],
"triggers": [TriggerRequest]
}
```
--------------------------------
### PageInfo Type Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example structure for pagination information, including current page, page size, and total pages.
```json
{"currentPage": 123, "pageSize": 123, "totalPages": 987}
```
--------------------------------
### mse.context.getRecommendations
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/shared-services/storefront-events/sdk/context.md
Gets the Recommendations context.
```APIDOC
## mse.context.getRecommendations
### Description
Gets the `Recommendations` context.
### Syntax
```javascript
mse.context.getRecommendations();
```
```
--------------------------------
### Product Search Item Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example structure for a product returned by a search query. Includes applied query rules, highlights, and product view details.
```json
{
"attribute": "xyz789",
"matched_words": ["abc123"],
"value": "xyz789"
}
```
--------------------------------
### mse.context.getProduct
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/shared-services/storefront-events/sdk/context.md
Gets the Product context.
```APIDOC
## mse.context.getProduct
### Description
Gets the `Product` context.
### Syntax
```javascript
mse.context.getProduct();
```
```
--------------------------------
### mse.context.getStorefrontInstance
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/shared-services/storefront-events/sdk/context.md
Gets the StorefrontInstance context.
```APIDOC
## mse.context.getStorefrontInstance
### Description
Gets the `StorefrontInstance` context.
### Syntax
```javascript
mse.context.getStorefrontInstance();
```
```
--------------------------------
### ProductSearchItem Type Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example structure for a single product within search results. It includes query rule application, highlights, and product view data.
```json
{
"applied_query_rule": AppliedQueryRule,
"highlights": [Highlight],
"productView": ProductView
}
```
--------------------------------
### ProductSearchResponse Type Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example structure for the overall product search response. It contains facets, items, pagination info, related terms, suggestions, total count, and warnings.
```json
{
"facets": [Aggregation],
"items": [ProductSearchItem],
"page_info": SearchResultPageInfo,
"related_terms": [String],
"suggestions": [String],
"total_count": Int,
"warnings": [ProductSearchWarning]
}
```
--------------------------------
### Delete Simple Product API Example
Source: https://github.com/adobedocs/commerce-services/blob/main/redoc-static.html
Use this example to delete a simple product by specifying its SKU and scope. Ensure the product exists before attempting deletion.
```json
[
{"sku": "red-pants", "scope": {"locale": "en"}}
]
```
--------------------------------
### Product Search Query Example
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/optimizer/merchandising-services/using-the-api.md
An example cURL command to search for products using the `productSearch` GraphQL query. This query retrieves product details including SKU, name, description, and price.
```APIDOC
## POST https://na1-sandbox.api.commerce.adobe.com/{{tenantId}}/graphql
### Description
Searches for products using the `productSearch` GraphQL query. Retrieves a list of products based on a search term, including their IDs, SKUs, names, and prices.
### Method
POST
### Endpoint
`https://na1-sandbox.api.commerce.adobe.com/{{tenantId}}/graphql`
### Headers
- `Content-Type`: `application/json`
- `AC-View-ID`: (Required) The unique identifier assigned to the catalog view.
### Request Body
```json
{
"query": "query ProductSearch($search: String!) { productSearch( phrase: $search, page_size: 10) { items { productView { sku name description shortDescription images { url } ... on SimpleProductView { attributes { label name value } price { regular { amount { value currency } } roles } } } } } }",
"variables": {
"search": "your-string"
}
}
```
### Request Example
```shell
curl -X POST \
'https://na1-sandbox.api.commerce.adobe.com/{{tenantId}}/graphql' \
-H 'Content-Type: application/json' \
-H 'AC-View-ID: {{catalogViewId}}' \
-d '{"query": "query ProductSearch($search: String!) { productSearch( phrase: $search, page_size: 10) { items { productView { sku name description shortDescription images { url } ... on SimpleProductView { attributes { label name value } price { regular { amount { value currency } } roles } } } } } }", "variables": { "search": "your-string"}}'
```
```
--------------------------------
### Batch Channel Response Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/admin-api/index.html
Example response structure for the batchChannel mutation, showing created/updated channel details and any errors. The 'createdAt' and 'updatedAt' fields indicate whether a channel was newly created or updated.
```json
{
"data": {
"batchChannel": {
"channels": [
{
"channelId": "e3cbe432-71a2-47cb-938f-29af8be940ab",
"name": "Channel Web/Online & Offline",
"defaultPriceBookId": "PBA",
"scopes": [
{ "locale": "en_US" },
{ "locale": "en_UK" },
{ "locale": "es_ES" }
],
"policyIds": [
"c1bcfed9-4096-4068-aab5-d88f6f39cfad",
"a3f4e403-a720-4b27-a266-d69099ae2421"
],
"allowedPriceBookIds": [
"c1bcfed9-4096-4068-aab5-d88f6f39cfad",
"a3f4e403-a720-4b27-a266-d69099ae2421"
],
"createdAt": "2024-11-08T14:55:37.938",
"updatedAt": "2024-11-12T11:13:22.554967"
},
{
"channelId": "f485f368-3a5a-497b-a13e-4fff8c66df09",
"name": "Offline Channel",
"defaultPriceBookId": "PBB",
"scopes": [
{ "locale": "en_UK" },
{ "locale": "fr_FR" }
],
"policyIds": [
"c1bcfed9-4096-4068-aab5-d88f6f39cfad",
"a3f4e403-a720-4b27-a266-d69099ae2421"
],
"allowedPriceBookIds": [
"c1bcfed9-4096-4068-aab5-d88f6f39cfad",
"a3f4e403-a720-4b27-a266-d69099ae2421"
],
"createdAt": "2024-11-12T11:13:22.562566",
"updatedAt": "2024-11-12T11:13:22.562566"
}
],
"errors": []
}
},
"extensions": {
"request-id": "d5863f2f668d897a"
}
}
```
--------------------------------
### Get Magento Extension Context
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/shared-services/storefront-events/sdk/context.md
Retrieves the MagentoExtension context. Use this to get information about installed Magento extensions.
```javascript
mse.context.getMagentoExtension();
```
--------------------------------
### Full SDK Workflow Example
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/product-recommendations/index.md
Demonstrates a complete workflow from importing the SDK, creating a client, registering a recommendation unit, fetching recommendations, and rendering the output.
```APIDOC
## Using the SDK from start to finish
### Description
The following example shows a sample workflow beginning with importing the SDK to rendering the recommendation.
### Code Example
```javascript
import RecommendationsClient from "@magento/recommendations-js-sdk"
// create the client
const client = new RecommendationsClient()
// register pre-built recommendation unit
client.register({
name: "Most Viewed Products",
type: "most-viewed",
})
// retrieve recommendations for all units
const {status, data} = await client.fetch()
// render the markup
const markup = client.render({
unit: data.units[0],
})
// insert the markup
document.body.insertAdjacentHTML("beforeend", markup)
```
```
--------------------------------
### Get credentials and access tokens
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/optimizer/data-ingestion/authentication.md
This snippet demonstrates how to obtain IMS credentials and access tokens for API authentication. It requires an initial setup for API access.
```javascript
import IMSAuth from '/src/_includes/authentication/initial-auth-for-api-access.md'
```
--------------------------------
### Production Build and Serve for Documentation
Source: https://context7.com/adobedocs/commerce-services/llms.txt
Commands to create a production-ready build of the documentation site and serve it.
```bash
# Production build
yarn build
yarn serve
```
--------------------------------
### Get Full Update Status
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/reporting/update-cycle.md
Retrieves the most recent completed update-cycle result for a specific Commerce Intelligence client. The response includes job metadata such as type, status, start and end times, and the client's time zone abbreviation.
```APIDOC
## GET /client/:clientId/fullupdatestatus
### Description
Retrieves the most recent completed update-cycle result for a Commerce Intelligence client.
### Method
GET
### Endpoint
`https://api.rjmetrics.com/0.1/client/:clientId/fullupdatestatus`
### Parameters
#### Path Parameters
- **clientId** (integer) - Required - Your Commerce Intelligence client identifier.
#### Request Headers
- **X-RJM-API-Key** (string) - Required - Your Export API key
- **Accept** (string) - Optional - `application/json`
### Request Example
```bash
curl -H "X-RJM-API-Key: $EXPORT_API_KEY" \
-H "Accept: application/json" \
https://api.rjmetrics.com/0.1/client/194/fullupdatestatus
```
### Response
#### Success Response (200 OK)
- **clientId** (integer) - Commerce Intelligence client identifier.
- **lastCompletedUpdateJob** (object | null) - The most recent completed Full Update job.
- **id** (integer) - Update job ID.
- **type** (object) - Update job type.
- **id** (integer) - Update job type identifier (for example, `2`).
- **name** (string) - Update job type name (for example, `Full Update`).
- **start** (string) - Job start time in the client time zone (format: `YYYY-MM-DD HH:mm:ss`).
- **end** (string) - Job end time in the client time zone (format: `YYYY-MM-DD HH:mm:ss`).
- **status** (object) - Terminal status of the job.
- **id** (integer) - Terminal status identifier (for example, `4`).
- **name** (string) - Terminal status name (for example, `Completed Successfully`).
- **lastCompletedUpdateJobWithDataSync** (object | null) - Reserved for "Full Update + Data Sync" jobs; may be null if not applicable.
- **timezoneAbbreviation** (string) - Client time zone abbreviation (for example, `EST`).
#### Response Example
```json
{
"clientId": 194,
"lastCompletedUpdateJob": {
"id": 13554,
"type": { "id": 2, "name": "Full Update" },
"start": "2025-12-09 03:26:25",
"end": "2025-12-09 03:29:03",
"status": { "id": 4, "name": "Completed Successfully" }
},
"lastCompletedUpdateJobWithDataSync": null,
"timezoneAbbreviation": "EST"
}
```
### Error Responses
- **403** - Malformed path or headers, Missing/invalid API key, Key lacks access to the client, Unknown clientId
- **429** - Rate limit exceeded
- **5xx** - Service error
```
--------------------------------
### ProductViewVideo Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Details about a product video, including its preview image and URL.
```json
{
"preview": ProductViewImage,
"url": "xyz789",
"description": "xyz789",
"title": "xyz789"
}
```
--------------------------------
### Live Development Preview of Merchandising API Reference
Source: https://context7.com/adobedocs/commerce-services/llms.txt
Starts a development server for live previewing the Merchandising API reference documentation. Useful for iterative development.
```bash
# Live development preview of Merchandising API reference
yarn dev:merchandising-api
```
--------------------------------
### Create or Replace Products
Source: https://context7.com/adobedocs/commerce-services/llms.txt
Use POST to create simple, configurable, or bundle products. Each product requires a unique `sku`, `source`, `name`, `slug`, and `status`. Products are linked to categories via the `routes` array using matching category slugs.
```bash
curl -X POST \
'https://na1-sandbox.api.commerce.adobe.com/YOUR_TENANT_ID/v1/catalog/products' \
-H 'Content-Type: application/json' \
-H 'Authorization: YOUR_ACCESS_TOKEN' \
-d "[
{
"sku": "T-SHIRT-RED",
"source": { "locale": "en-US" },
"name": "Red T-Shirt",
"slug": "red-t-shirt",
"status": "ENABLED",
"categories": ["men/clothing/tops"],
"attributes": [
{ "code": "color", "value": "Red" },
{ "code": "size", "value": "M" }
]
}
]"
```
--------------------------------
### String Scalar Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/admin-api/index.html
Example of a String scalar type, representing textual data.
```json
"xyz789"
```
--------------------------------
### Initialize Recommendations Client
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/product-recommendations/index.md
Initialize the client by calling `new RecommendationsClient()`. The SDK automatically retrieves store configuration values.
```javascript
const client = new RecommendationsClient()
```
--------------------------------
### Create Configurable Product with Variants
Source: https://context7.com/adobedocs/commerce-services/llms.txt
This example demonstrates creating a configurable product with multiple variants based on attributes like color and size. Each variant must be linked to the parent configurable product.
```curl
curl -X POST \
'https://na1-sandbox.api.commerce.adobe.com/YOUR_TENANT_ID/v1/catalog/products' \
-H 'Content-Type: application/json' \
-H 'Authorization: YOUR_ACCESS_TOKEN' \
-d '[\
{\
"sku": "pants",\
"source": { "locale": "en-US" },\
"name": "Yoga Pants",\
"slug": "zeppelin-yoga-pant",\
"status": "ENABLED",\
"visibleIn": ["CATALOG"],\
"configurations": [\
{\
"attributeCode": "color",\
"label": "Color",\
"defaultVariantReferenceId": "pants-color-red",\
"type": "SWATCH",\
"values": [\
{ "variantReferenceId": "pants-color-red", "label": "Red", "colorHex": "#ff0000" },\
{ "variantReferenceId": "pants-color-green", "label": "Green", "colorHex": "#00ff00" }\
]\
},\
{\
"attributeCode": "size",\
"label": "Size",\
"defaultVariantReferenceId": "pants-size-32",\
"type": "CONFIGURABLE",\
"values": [\
{ "variantReferenceId": "pants-size-32", "label": "32" },\
{ "variantReferenceId": "pants-size-44", "label": "44" }\
]\
}\
]
},
{\
"sku": "pants-red-32",\
"source": { "locale": "en-US" },\
"name": "Yoga Pants Red 32",\
"slug": "pants-red-32",\
"status": "ENABLED",\
"attributes": [\
{ "code": "color", "values": ["Red"], "variantReferenceId": "pants-color-red" },\
{ "code": "size", "values": ["32"], "variantReferenceId": "pants-size-32" }\
],
"links": [{ "type": "VARIANT_OF", "sku": "pants" }]
},
{\
"sku": "pants-green-44",\
"source": { "locale": "en-US" },\
"name": "Yoga Pants Green 44",\
"slug": "pants-green-44",\
"status": "ENABLED",\
"attributes": [\
{ "code": "color", "values": ["Green"], "variantReferenceId": "pants-color-green" },\
{ "code": "size", "values": ["44"], "variantReferenceId": "pants-size-44" }\
],
"links": [{ "type": "VARIANT_OF", "sku": "pants" }]
}\
]'
```
--------------------------------
### PriceAdjustment Type Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example structure for a price adjustment, specifying the amount and type of adjustment.
```json
{"amount": 123.45, "code": "abc123"}
```
--------------------------------
### Create a Configurable Product with Variants
Source: https://github.com/adobedocs/commerce-services/blob/main/redoc-static.html
This snippet demonstrates creating a configurable product with multiple variants. It defines configuration options like color and size, linking them to specific variant SKUs. Each variant must also be defined with its attributes and a link to the parent configurable product.
```json
{
"sku": "pants",
"scope": {
"locale": "en"
},
"name": "Yoga pants",
"slug": "zeppelin-yoga-pant",
"status": "ENABLED",
"visibleIn": [
"CATALOG"
],
"configurations": [
{
"attributeCode": "color",
"label": "Pants color",
"defaultVariantReferenceId": "pants-color-red",
"type": "SWATCH",
"values": [
{
"variantReferenceId": "pants-color-red",
"label": "Red",
"colorHex": "#ff0000"
},
{
"variantReferenceId": "pants-color-green",
"label": "Green",
"imageUrl": "https://www.example.com/media/catalog/product/green_main_1.jpg"
}
]
},
{
"attributeCode": "size",
"label": "Pants size",
"defaultVariantReferenceId": "pants-size-32",
"type": "CONFIGURABLE",
"values": [
{
"variantReferenceId": "pants-size-32",
"label": "32"
},
{
"variantReferenceId": "pants-size-44",
"label": "44"
}
]
}
]
}
```
```json
{
"sku": "pants-red-32",
"scope": {
"locale": "en"
},
"name": "Zeppelin Yoga Pant Red 32 size",
"slug": "pants-red-32",
"status": "ENABLED",
"attributes": [
{
"code": "color",
"type": "STRING",
"values": [
"Red Pants"
],
"variantReferenceId": "pants-color-red"
},
{
"code": "size",
"type": "STRING",
"values": [
"32"
],
"variantReferenceId": "pants-size-32"
}
],
"links": [
{
"type": "variant_of",
"sku": "pants"
}
]
}
```
```json
{
"sku": "pants-red-44",
"scope": {
"locale": "en"
},
"name": "Zeppelin Yoga Pant Red 44 size",
"slug": "pants-red-44",
"status": "ENABLED",
"attributes": [
{
"code": "color",
"type": "STRING",
"values": [
"Red Pants"
],
"variantReferenceId": "pants-color-red"
},
{
"code": "size",
"type": "STRING",
"values": [
"44"
],
"variantReferenceId": "pants-size-44"
}
],
"links": [
{
"type": "VARIANT_OF",
"sku": "pants"
}
]
}
```
```json
{
"sku": "pants-green-32",
"scope": {
"locale": "en"
},
"name": "Zeppelin Yoga Pant Green 32 size",
"slug": "pants-green-32",
"status": "ENABLED",
"attributes": [
{
"code": "color",
"type": "STRING",
"values": [
"Green Pants"
],
"variantReferenceId": "pants-color-green"
},
{
"code": "size",
"type": "STRING",
"values": [
"32"
],
"variantReferenceId": "pants-size-32"
}
],
"links": [
{
"type": "variant_of",
"sku": "pants"
}
]
}
```
```json
{
"sku": "pants-green-44",
"scope": {
"locale": "en"
},
"name": "Zeppelin Yoga Pant green 44 size",
"slug": "pants-green-44",
"status": "ENABLED",
"attri
```
--------------------------------
### ProductViewOption Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Represents a product option with its ID, multi-select capability, required status, title, and available values.
```json
{
"id": 4,
"multi": false,
"required": false,
"title": "xyz789",
"values": [ProductViewOptionValue]
}
```
--------------------------------
### JSON Scalar Type Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example of the JSON scalar type, representing a JSON object.
```json
{}
```
--------------------------------
### Transport Type Enum Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/admin-api/index.html
Example value for the TransportType enum, currently supporting HTTP_HEADER.
```json
"HTTP_HEADER"
```
--------------------------------
### Product Search Query with Curl
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/optimizer/merchandising-services/using-the-api.md
This example demonstrates how to search for products using the `productSearch` query via curl. It retrieves product details including SKU, name, description, and price. Ensure you replace 'your-string' with your actual search term.
```bash
curl -X POST \
'https://na1-sandbox.api.commerce.adobe.com/{{tenantId}}/graphql' \
-H 'Content-Type: application/json' \
-H 'AC-View-ID: {{catalogViewId}}' \
-d '{"query": "query ProductSearch($search: String!) { productSearch( phrase: $search, page_size: 10) { items { productView { sku name description shortDescription images { url } ... on SimpleProductView { attributes { label name value } price { regular { amount { value currency } } roles } } } } } }", "variables": { "search": "your-string"}}'
```
--------------------------------
### Action Filter Response Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/admin-api/index.html
An example of the ActionFilterResponse object, representing a configured action filter.
```json
{
"actionFilterOperator": "EQUALS",
"attribute": "xyz789",
"enabled": false,
"value": "abc123",
"valueSource": "STATIC",
"values": ["abc123"]
}
```
--------------------------------
### Push Data Example (Python)
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/reporting/import-api.md
This Python code snippet demonstrates how to push data to a table using the client library. Replace 'table_name' and 'test_data' with your actual table and data.
```python
client.push_data(
"table_name",
test_data
)
```
--------------------------------
### CategoryMetaTags Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Provides an example of SEO metadata tags for a category, including title, description, and keywords.
```json
{
"title": "abc123",
"description": "abc123",
"keywords": ["xyz789"]
}
```
--------------------------------
### Action Response Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/admin-api/index.html
An example of the ActionResponse object, detailing the filters and triggers associated with a policy action.
```json
{
"filters": [ActionFilterResponse],
"triggers": [TriggerResponse]
}
```
--------------------------------
### RecommendationUnit Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Contains product and other details for a recommendation unit.
```json
{
"displayOrder": 987,
"pageType": "xyz789",
"productsView": [ProductView],
"storefrontLabel": "abc123",
"totalProducts": 987,
"typeId": "abc123",
"unitId": "abc123",
"unitName": "abc123"
}
```
--------------------------------
### mse.subscribe.initiateCheckout
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/shared-services/storefront-events/sdk/subscribe.md
Subscribes to the `initiateCheckout` event. It takes an event handler and optional listener options.
```APIDOC
## mse.subscribe.initiateCheckout
### Description
Subscribes to the `initiateCheckout` event.
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
- **handler** (function) - Required - The event handler function to execute when the event occurs.
- **options** (object) - Optional - Listener options for the subscription.
```
--------------------------------
### Build API Docs Locally with Redocly CLI
Source: https://github.com/adobedocs/commerce-services/blob/main/static/rest/README.md
Use this command to generate a local HTML preview of the API documentation. Ensure you have the Redocly CLI installed and specify the correct schema and configuration file paths.
```shell
npx @redocly/cli build-docs static/rest/data-ingestion-schema-v1.yaml --config static/rest/.redocly.yaml --output tmp/redoc-static.html
```
--------------------------------
### POST /v1/catalog/products
Source: https://context7.com/adobedocs/commerce-services/llms.txt
Creates simple products, configurable products (with variants), and bundle products. Each product requires a unique `sku`, `source`, `name`, `slug`, and `status`. Products are linked to categories via the `routes` array using matching category slugs.
```APIDOC
## POST /v1/catalog/products — Create or Replace Products
### Description
Creates simple products, configurable products (with variants), and bundle products. Each product requires a unique `sku`, `source`, `name`, `slug`, and `status`. Products are linked to categories via the `routes` array using matching category slugs.
### Method
POST
### Endpoint
`/v1/catalog/products`
### Request Body
- **sku** (string) - Required - The unique Stock Keeping Unit for the product.
- **source** (object) - Required - The source object, typically containing locale.
- **locale** (string) - Required - The locale for the product.
- **name** (string) - Required - The display name of the product.
- **slug** (string) - Required - The unique slug for the product.
- **status** (string) - Required - The status of the product (e.g., `ENABLED`, `DISABLED`).
- **routes** (array) - Optional - An array of category slugs the product belongs to.
- **variants** (array) - Optional - An array of product variants for configurable products.
- **bundleItems** (array) - Optional - An array of items for bundle products.
### Request Example
```json
[
{
"sku": "TSHIRT-RED-L",
"source": { "locale": "en-US" },
"name": "Red T-Shirt - Large",
"slug": "red-tshirt-large",
"status": "ENABLED",
"routes": ["men/clothing/shirts"],
"variants": [
{
"sku": "TSHIRT-RED-M",
"source": { "locale": "en-US" },
"name": "Red T-Shirt - Medium",
"slug": "red-tshirt-medium",
"status": "ENABLED",
"routes": ["men/clothing/shirts"]
}
]
}
]
```
### Response
#### Success Response (200)
- **status** (string) - The status of the operation (e.g., "ACCEPTED").
- **acceptedCount** (integer) - The number of products accepted for processing.
```
--------------------------------
### Get Page Context
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/shared-services/storefront-events/sdk/context.md
Retrieves the Page context. Use this to get information about the current storefront page.
```javascript
mse.context.getPage();
```
--------------------------------
### Product Recommendations JavaScript SDK - Fetching and Rendering
Source: https://context7.com/adobedocs/commerce-services/llms.txt
Fetch recommendations using the initialized client, providing context like current SKU or cart items. Render the results using a template.
```javascript
// Fetch all registered units
const { status, data } = await client.fetch({
currentSku: "red-pants", // for page-context recommendations
cartSkus: ["pants-red-32"], // cart-aware recommendations
limit: 10,
offset: 0,
})
// Render using mustache.js template
const markup = client.render({
unit: data.units[0],
// Template variables: {{url}}, {{image}}, {{title}}, {{price}}
})
document.querySelector("#recommendations").insertAdjacentHTML("beforeend", markup)
// Response shape from client.fetch():
// {
// "units": [{
// "unitId": "45687",
// "unitName": "Most Viewed Products",
// "totalResults": 3,
// "results": [{
// "rank": 1, "score": 0.38, "sku": "35123",
// "name": "Pursuit Lumaflex Tone Band",
// "currency": "USD",
// "prices": { "maximum": { "final": 16.0, "regular": 16.0 } },
// "image": { "label": "", "url": "http://..." }
// }]
// }]
// }
```
--------------------------------
### AttributeMetadataResponse Object Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example of the AttributeMetadataResponse object, which contains arrays of product attributes that are filterable in search and sortable.
```json
{
"filterableInSearch": [FilterableInSearchAttribute],
"sortable": [SortableAttribute]
}
```
--------------------------------
### Development Build Command
Source: https://github.com/adobedocs/commerce-services/blob/main/spectaql/README.md
Starts SpectaQL in development mode, introspecting the live GraphQL endpoint on each run. Requires .env with tenant and catalog view IDs.
```bash
yarn dev:merchandising-api
```
--------------------------------
### Action Filter Request Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/admin-api/index.html
An example of the ActionFilterRequest input object, used for defining filters in policy operations.
```json
{
"actionFilterOperator": "EQUALS",
"attribute": "abc123",
"enabled": false,
"value": "xyz789",
"valueSource": "STATIC",
"values": ["abc123"]
}
```
--------------------------------
### Build Both GraphQL API References
Source: https://context7.com/adobedocs/commerce-services/llms.txt
Executes commands to build both the Merchandising and Admin GraphQL API reference documentation.
```bash
# Build both GraphQL references
yarn build:graphql
```
--------------------------------
### Product Recommendations JavaScript SDK - Initialization and Registration
Source: https://context7.com/adobedocs/commerce-services/llms.txt
Initialize the client-side SDK for fetching and rendering product recommendations. Register built-in or custom recommendation units with specific filters.
```javascript
import RecommendationsClient from "@magento/recommendations-js-sdk"
// Or via CDN:
// Initialize the client (auto-reads environmentId, instanceId, storeCode, etc.)
const client = new RecommendationsClient()
// Register a built-in recommendation unit
client.register({
name: "Most Viewed Products",
type: "most-viewed",
})
// Register a filtered recommendation (max price $200, specific categories)
client.register({
name: "Trending Pants Under $200",
type: "trending",
filter: "categories: (men-clothing-pants) AND prices.maximum.regular: <200",
})
// Register a custom query-based recommendation
client.register({
name: "Related Parts",
type: "custom",
search: {
signal: "query",
key: "categories:(suspension OR brakes)",
},
})
```
--------------------------------
### Example JSON Response for Accepted Request
Source: https://github.com/adobedocs/commerce-services/blob/main/redoc-static.html
This is an example of a successful JSON response indicating that a request has been accepted and providing a count of accepted items.
```json
{ * "status": "ACCEPTED", * "acceptedCount": 4 }
```
--------------------------------
### Int Scalar Type Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
Example of the Int scalar type, representing non-fractional signed whole numbers within a specific range.
```json
987
```
--------------------------------
### ProductViewOptionValueConfiguration Example
Source: https://github.com/adobedocs/commerce-services/blob/main/static/graphql-api/merchandising-api/index.html
An implementation of ProductViewOptionValue for configuration values, including ID, title, and stock status.
```json
{
"id": "4",
"title": "abc123",
"inStock": true
}
```
--------------------------------
### Install Python Reporting API Client
Source: https://github.com/adobedocs/commerce-services/blob/main/src/pages/reporting/libraries.md
Install the RJMetrics Python client library using pip. This command is suitable for most Python environments.
```bash
pip install rjmetrics
```
--------------------------------
### Build Merchandising API Reference
Source: https://github.com/adobedocs/commerce-services/blob/main/README.md
Execute this command to generate the Merchandising GraphQL API reference documentation.
```bash
yarn build:merchandising-api
```