Storefront configuration
In this section, you’ll learn how Commerce blocks in your storefront connect to a Commerce backend using values from either your site’s public config or a config.json file in your code repo.
The configuration is organized into several key sections:
- Endpoints - GraphQL endpoints for Commerce and Catalog Services
- Headers - HTTP headers required for API authentication and store context
- Analytics - Store and environment metadata for tracking and reporting
- Plugins - Configuration for various Edge Delivery Services plugins and features
- Multistore - Settings for multiple store views and internationalization
When implementing your own project, you must update the configuration values with:
- The Adobe Commerce and Catalog Service GraphQL endpoint that you configured as part of the content delivery network (CDN) setup.
- The header values specific to your Adobe Commerce Catalog Services environment.
If you set up your storefront using the boilerplate code, the template repo provides you with a demo-config.json
file in the root folder. This file contains the environment values for a Commerce backend including GraphQl endpoints and headers.
If you set up your site using the Site Creator Tool, the config.json
file is created and added to the GitHub repository created for the boilerplate code. You can review and update the default values in the config.json
file after the process completes.
Vocabulary
Storefront configuration
A JSON object that maps properties and values used by the Commerce boilerplate.
The storefront configuration is a JSON object which lives in the config-service and contains the connection settings for your Commerce blocks. The boilerplate repo also contains a demo-config.json
file that can be renamed to config.json
instead of using the config service, although we suggest using the config service.
At the root, there is a public
property which should not be changed, and a nested default
object. This default
object is the root level configuration that is used for your storefront. The config object contains properties and values which correspond to a specific setting or usage in your Commerce backend.
If you use aem.live’s config service, your config will live at https://admin.hlx.page/config/{{ORG}}/sites/{{SITE}}/public.json
but can be overwritten with a local /config.json
file in your code repo.
default values
By default, the values in the demo-config.json
file are from the boilerplate’s sample backend to ensure everything works out of the box. But when it comes time to connect your own backend, you need to know what each key means so you can update it with the correct value from your own Commerce instance.
getConfigValue function
The getConfigValue
function is a helper function that retrieves the value
from the configs
file using the dot-notation path as an argument. For example, getConfigValue('headers.cs.x-api-key')
returns the value of [root config].headers.cs.x-api-key
.
getHeaders function
The getHeaders
function is a helper function which takes a storefront scope (like cs
, cart
, etc) and reads values from the configs file with the corresponding header
keys and returns an object map of those rows. For example, if you have properties in config like headers.cs.Magento-Environment-Id": "abc-123"
, then getHeaders('cs')
will return an object like { "Magento-Environment-Id": "abc-123"}
.
Configuration Sections
The following sections detail each part of your configuration for Adobe Commerce. Each section includes placeholders (marked with {{PLACEHOLDER}}
) that you must replace with your specific Commerce environment details.
You can find your configuration in your code repo at /config.json
or /demo-config.json
, or in the config service for your site. If you do not have a configuration yet, use the Config Generator tool to automatically generate the configuration for your backend.
Endpoints
The endpoints properties define the GraphQL API endpoints for your Commerce backend.
{ "commerce-core-endpoint": "{{COMMERCE_CORE_ENDPOINT}}", "commerce-endpoint": "{{COMMERCE_ENDPOINT}}"}
Configuration Properties:
-
commerce-core-endpoint
(read/write) - Core GraphQL endpoint for queries and mutations. This endpoint handles all write operations and some read operations. See Adobe Commerce GraphQL API for details. -
commerce-endpoint
(read-only) - Services GraphQL endpoint optimized for read-only operations with Catalog Service, Live Search, and Product Recommendations. It is also optimized for performance for product data retrieval. For details, see the following documentation:- For Adobe Commerce as a Cloud Service, see the Catalog Service Guide.
- For Adobe Commerce Optimizer, see the Merchandising Services Developer Guide
Headers
The headers section defines HTTP headers required for API authentication and store context. Headers are organized by scope to apply different authentication and context settings for different request types. The specific headers required depend on your Commerce environment type.
Adobe Commerce PaaS environments use standard Adboe Commerce header naming conventions and require API keys for SaaS services.
{ "headers": { "all": { "Store": "{{STORE_VIEW_CODE}}" }, "cs": { "Magento-Store-Code": "{{STORE_CODE}}", "Magento-Store-View-Code": "{{STORE_VIEW_CODE}}", "Magento-Website-Code": "{{WEBSITE_CODE}}", "x-api-key": "{{API_KEY}}", "Magento-Environment-Id": "{{ENVIRONMENT_ID}}" } }}
Header Scopes:
-
all
- Headers applied to all GraphQL requestsStore
- Store view code for Core GraphQL requests. See GraphQL Headers for details.
-
cs
- Headers for Catalog Service requestsMagento-Store-Code
- Store to connect to. See Create stores for details.Magento-Store-View-Code
- Store view for Catalog Service requests. See Store views for details.Magento-Website-Code
- Website to connect to. See Create websites for details.x-api-key
- API key for SaaS services (Catalog Service, Live Search, Product Recommendations). See Commerce Services Connector for details.Magento-Environment-Id
- Connects the storefront to the cloud instance serving it. See Cloud Environment overview for details.
Adobe Commerce as a Cloud Service uses standard Adobe Commerce header naming conventions but does not require API keys or environment IDs in the default configuration.
{ "headers": { "all": { "Store": "{{STORE_VIEW_CODE}}" }, "cs": { "Magento-Store-Code": "{{STORE_CODE}}", "Magento-Store-View-Code": "{{STORE_VIEW_CODE}}", "Magento-Website-Code": "{{WEBSITE_CODE}}" } }}
Header Scopes:
-
all
- Headers applied to all GraphQL requestsStore
- Store view code for Core GraphQL requests. See GraphQL Headers for details.
-
cs
- Headers for Catalog Service requestsMagento-Store-Code
- Store to connect to. See Create stores for details.Magento-Store-View-Code
- Store view for Catalog Service requests. See Store views for details.Magento-Website-Code
- Website to connect to. See Create websites for details.
Adobe Commerce Optimizer uses different header naming conventions and requires Commerce Optimizer-specific headers as defined in the Merchandising Services API documentation.
{ "headers": { "cs": { "AC-View-ID": "{{CATALOG_VIEW_ID}}", "AC-Source-Locale": "{{LOCALE}}", "AC-Price-Book-ID": "{{PRICE_BOOK_ID}}", "AC-Policy-{{*}}": "{{ATTRIBUTE_VALUE}}" } }}
Header Scopes:
cs
- Headers applied to all GraphQL requestsAC-View-ID
- (Required) The unique ID assigned to the catalog view that products will be sold through. You can find this in the Adobe Commerce Optimizer UI.AC-Source-Locale
- (Required) Catalog source locale (language or geography) to filter products for display, for exampleen_US
. See the catalog view configuration to determine the correct value.AC-Price-Book-ID
- (Optional) Defines how prices are calculated for a specific catalog view. If not included, Merchandising Services provides a default price book with currency in US dollars.AC-Policy-{{*}}
- (Optional) Policy trigger for filtering products by attribute. The header should match the “name” of the trigger. For example,AC-Policy-Brand:Cruz
for brand filtering using “Cruz”. You can specify multiple policy headers per request.
Analytics
The analytics section contains store and environment metadata for tracking and reporting. The specific values depend on your Commerce environment type.
For Adobe Commerce PaaS and Adobe Commerce as a Cloud Service environments, use standard Commerce store and website identifiers from your Commerce Environment. You can obtain these values using a storeConfig
query.
{ "analytics": { "base-currency-code": "{{CURRENCY_CODE}}", "environment": "{{ENVIRONMENT_TYPE}}", "environment-id": "{{ENVIRONMENT_ID}}", "store-code": "{{STORE_CODE}}", "store-id": {{STORE_ID}}, "store-name": "{{STORE_NAME}}", "store-url": "{{STORE_URL}}", "store-view-code": "{{STORE_VIEW_CODE}}", "store-view-id": {{STORE_VIEW_ID}}, "store-view-name": "{{STORE_VIEW_NAME}}", "website-code": "{{WEBSITE_CODE}}", "website-id": {{WEBSITE_ID}}, "website-name": "{{WEBSITE_NAME}}" }}
Configuration Properties:
base-currency-code
- The base currency code for the store (e.g., “USD”, “EUR”)environment
- Environment type (“Production”, “Testing”)environment-id
- Unique identifier for the Commerce environmentstore-url
- Base URL for the storestore-code
- Code identifier for the store from your Commerce environmentstore-id
- Numeric ID for the storestore-name
- Display name for the storestore-view-code
- Code identifier for the store viewstore-view-id
- Numeric ID for the store viewstore-view-name
- Display name for the store viewwebsite-code
- Code identifier for the website from your Commerce environmentwebsite-id
- Numeric ID for the websitewebsite-name
- Display name for the website
For Adobe Commerce Optimizer environments, note the use of hardcoded values for store-code
and website-code
.
{ "analytics": { "base-currency-code": "{{CURRENCY_CODE}}", "environment": "{{ENVIRONMENT_TYPE}}", "environment-id": "{{YOUR_TENANT_ID}}", "store-code": "STORE_CODE", "store-id": {{STORE_ID}}, "store-name": "{{STORE_NAME}}", "store-url": "{{STORE_URL}}", "store-view-code": "{{YOUR_AC-SOURCE-LOCALE_HEADER}}", "store-view-id": {{STORE_VIEW_ID}}, "store-view-name": "{{STORE_VIEW_NAME}}", "website-code": "WEBSITE_CODE", "website-id": {{WEBSITE_ID}}, "website-name": "{{WEBSITE_NAME}}" }}
Configuration Properties:
base-currency-code
- The base currency code for the store (e.g., “USD”, “EUR”)environment
- Environment type (“Production”, “Testing”)environment-id
- The tenant ID for the Adobe Commerce Optimizer instancestore-url
- Base URL for the storestore-code
- Hardcoded value STORE_CODE for ACO environmentsstore-id
- Numeric ID for the storestore-name
- Display name for the storestore-view-code
- Matches the AC-Source-Locale header valuestore-view-id
- Numeric ID for the store viewstore-view-name
- Display name for the store viewwebsite-code
- Hardcoded value WEBSITE_CODE for ACO environmentswebsite-id
- Numeric ID for the websitewebsite-name
- Display name for the website
Plugins
The plugins section configures various Commerce plugins and features.
{ "plugins": { "picker": { "rootCategory": "{{ROOT_CATEGORY_ID}}" } }}
Configuration Properties:
picker.rootCategory
- Root category ID for the product picker. This determines which category serves as the starting point when browsing products in the Commerce interface.
Multistore
The multistore section manages configurations for multiple store views and internationalization. This allows different configurations for different locales or store views. Each non-”default” configuration will be merged with the default at runtime and used for the corresponding locale or store view. For example, the below would serve as a basis for configuration for the site at aemshop.net/fr.
{ "/fr/": { "headers": { "all": { "Store": "{{FRENCH_STORE_VIEW_CODE}}" }, "cs": { "Magento-Store-Code": "{{FRENCH_STORE_CODE}}", "Magento-Website-Code": "{{FRENCH_WEBSITE_CODE}}", "Magento-Store-View-Code": "{{FRENCH_STORE_VIEW_CODE}}" } } }}
Configuration Properties:
- Path-based configuration - Use URL paths (like
/fr/
,/de/
, etc.) to define locale-specific or store-specific overrides - Header overrides - Override default headers for specific store views
- Store context - Define different store, website, and store view codes for each locale
Additional Configuration Options
Some configuration options can be set to enable or disable certain boilerplate features.
{ "commerce-assets-enabled": boolean, "commerce-companies-enabled": boolean,}
commerce-assets-enabled
- Boolean flag to enable or disable AEM Assets within the storefrontcommerce-companies-enabled
- Boolean flag to enable or disable Commerce B2B features within the storefront
Configuration Examples
The following examples show real config.json
files from different Adobe Commerce environments. These examples demonstrate the actual structure and values used in production environments.
This example shows the configuration for an Adobe Commerce PaaS environment, which includes additional features like multistore support and asset management. This configuration is used on this site: https://www.aemshop.net/
{ "public": { "default": { "commerce-core-endpoint": "https://www.aemshop.net/graphql", "commerce-endpoint": "https://www.aemshop.net/cs-graphql", "headers": { "all": { "Store": "default" }, "cs": { "Magento-Store-Code": "main_website_store", "Magento-Store-View-Code": "default", "Magento-Website-Code": "base", "x-api-key": "4dfa19c9fe6f4cccade55cc5b3da94f7", "Magento-Environment-Id": "f38a0de0-764b-41fa-bd2c-5bc2f3c7b39a" } }, "analytics": { "base-currency-code": "USD", "environment": "Production", "environment-id": "f38a0de0-764b-41fa-bd2c-5bc2f3c7b39a", "store-code": "main_website_store", "store-id": 1, "store-name": "Main Website Store", "store-url": "https://www.aemshop.net", "store-view-code": "default", "store-view-id": 1, "store-view-name": "Default Store View", "website-code": "base", "website-id": 1, "website-name": "Main Website" }, "plugins": { "picker": { "rootCategory": "2" } }, "commerce-assets-enabled": false }, "/fr/": { "headers": { "all": { "Store": "fr" }, "cs": { "Magento-Store-Code": "fr_store", "Magento-Website-Code": "fr_website", "Magento-Store-View-Code": "fr" } } } }}
This example shows the configuration for Adobe Commerce as a Cloud Service, which uses standard Adobe Commerce header naming conventions. This configuration is used on this site: https://main—boilerplate-accs—adobe-commerce.aem.live/
{ "public": { "default": { "commerce-core-endpoint": "https://na1-sandbox.api.commerce.adobe.com/LwndYQs37CvkUQk9WEmNkz/graphql", "commerce-endpoint": "https://na1-sandbox.api.commerce.adobe.com/LwndYQs37CvkUQk9WEmNkz/graphql", "headers": { "all": { "Store": "default" }, "cs": { "Magento-Store-Code": "main_website_store", "Magento-Store-View-Code": "default", "Magento-Website-Code": "base" } }, "analytics": { "base-currency-code": "USD", "environment": "Testing", "environment-id": "LwndYQs37CvkUQk9WEmNkz", "store-code": "main_website_store", "store-id": 1, "store-name": "ACCS Store", "store-url": "https://main--boilerplate-accs--adobe-commerce.aem.live", "store-view-code": "default", "store-view-id": 1, "store-view-name": "Default Store View", "website-code": "base", "website-id": 1, "website-name": "Main Website" }, "plugins": { "picker": { "rootCategory": "2" } } } }}
This example shows the configuration for Adobe Commerce Optimizer, which uses different header naming conventions and includes Commerce Optimizer-specific settings. This configuration is used on this site: https://main—boilerplate-aco—adobe-commerce.aem.live/
{ "public": { "default": { "commerce-core-endpoint": "https://na1-sandbox.api.commerce.adobe.com/8idEEDDiVwjCEJAyB5kjfi/graphql", "commerce-endpoint": "https://na1-sandbox.api.commerce.adobe.com/8idEEDDiVwjCEJAyB5kjfi/graphql", "headers": { "cs": { "ac-view-id": "0d3eebf7-b5fb-4904-9ccf-f35fcc61862b", "ac-price-book-id": "west_coast_inc", "ac-scope-locale": "en-US" } }, "analytics": { "base-currency-code": "USD", "environment": "Testing", "environment-id": "8idEEDDiVwjCEJAyB5kjfi", "store-code": "STORE_CODE", "store-id": 1, "store-name": "ACO Store", "store-url": "https://main--boilerplate-aco--adobe-commerce.aem.live", "store-view-code": "en-US", "store-view-id": 1, "store-view-name": "Default Store View", "website-code": "WEBSITE_CODE", "website-id": 1, "website-name": "Main Website" }, "plugins": { "picker": { "rootCategory": "2" } } } }}
Step-by-step
We’ll use a mock PDP / Catalog Service block to demonstrate how to utilize the config utilities and values. This example shows how to access the configuration sections detailed above.
Import the configuration functions.
First, import the getConfigValue
and getHeaders
functions from your boilerplate’s scripts/configs.js
file.
import { getConfigValue, getHeaders } from '../../scripts/configs.js';
Access endpoint configuration.
Use the getConfigValue
function to retrieve endpoint URLs from the configuration. This function takes a dot-notation path that matches the keys in your config.json
.
export default async function decorate(block) { // Get the catalog service endpoint from the endpoints section const catalogEndpoint = await getConfigValue('commerce-endpoint'); const coreEndpoint = await getConfigValue('commerce-core-endpoint');
console.log('Catalog Service endpoint:', catalogEndpoint); console.log('Core Commerce endpoint:', coreEndpoint);}
Access header configuration.
Use the getHeaders
function to retrieve headers for specific scopes. This function automatically formats the headers for use in HTTP requests.
export default async function decorate(block) { // Get headers for Catalog Service requests const csHeaders = await getHeaders('cs');
// Get headers for all requests const allHeaders = await getHeaders('all');
console.log('CS headers:', csHeaders); console.log('All headers:', allHeaders);}
Access analytics and other configuration.
Use getConfigValue
to access any configuration value using dot notation, including analytics data and plugin settings.
export default async function decorate(block) { // Get analytics configuration const storeName = await getConfigValue('analytics.store-name'); const currency = await getConfigValue('analytics.base-currency-code');
// Get plugin configuration const rootCategory = await getConfigValue('plugins.picker.rootCategory');
console.log('Store:', storeName, 'Currency:', currency); console.log('Root category:', rootCategory);}
Make API requests with configuration.
Combine the endpoint and header configuration to make authenticated API requests to your Commerce backend.
export default async function decorate(block) { // Get the catalog service endpoint const endpoint = await getConfigValue('commerce-endpoint');
// Get the catalog service required headers const headers = await getHeaders('cs');
// Make the API request const response = await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json', ...headers }, body: JSON.stringify({ query: `query { products { items { name } } }` }) });
const data = await response.json(); // Process the response data}
Summary
The Commerce configuration provides a structured approach to connecting your storefront to Adobe Commerce backends. By organizing settings into clear sections for endpoints, headers, analytics, plugins, and multistore configurations, you can easily customize your storefront for different Commerce environments. The configuration system supports Adobe Commerce (PaaS), Adobe Commerce as a Cloud Service (ACCS), and Adobe Commerce Optimizer (ACO), each with specific header requirements and authentication methods. Use the getConfigValue
and getHeaders
helper functions to access these settings in your Commerce blocks, ensuring consistent and maintainable integration with your Commerce backend.