Skip to main content

Managing Data with Multiple Marketplaces

Theme developers sometimes have to work with marketplaces that has different environments, such as one for staging and another for production. In such cases, product IDs for the same products might differ by environment, so if you specify default data in custom templates (see Customized data), you might have to update the template whenever you upload new themes to the marketplace.

If you work in a multiple-environment scenario, you can use a JSON file to specify environment-specific values, such as product IDs, and thereby avoid manual updates to custom data.

In the env-data.json file, located in the theme root folder, specify the following information:

  • A full or partial marketplace path for each environment.

  • A list of attribute key/value pairs for each environment. You can retrieve the desired data in the data viewer. See Use the developer tool bar.

    You must specify the name and type attributes, as well as the item IDs. The Storefront Toolkit attempts to match the name values specified in the file with corresponding attribute names in the <data> tag in the theme. If there is no match (for example, the name value does not exist or the marketplace path is incorrect), the default marketplace values are used.

The following examples demonstrate the correct format to use.

Example: Two environments

In the following example, the product IDs in the hero slider are different for the production environment (at marketplace.sample.com) and testing environment (at testmarketplace.sample.com).

    {
"https://marketplace.sample.com": [
{
"name": "hero",
"type": "list",
"products": "185242,97079"
}
],
"https://testmarketplace.sample.com": [
{
"name": "hero",
"type": "list",
"products": "122221,119048"
}
]
}

Example: Multiple subdomains

The following example includes the sample.com domain as well as two subdomains. If there are numerous subdomains (for example, test environments), you can specify part of a domain to match. In this case, the sample.com product IDs would be used for all subdomains except the two full domains specified here.

    {
"https://marketplace.sample.com": [
{
"name": "hero",
"type": "list",
"products": "185242,97079"
}
],
"https://testmarketplace.sample.com": [
{
"name": "hero",
"type": "list",
"products": "122221,119048"
}
],
"sample.com": [
{
"name": "hero",
"type": "list",
"products": "168,47"
}
]
}

In this example, beta.sample.com, staging.sample.com, and test.sample.com would all use product IDs 168 and 47.

important

When you specify multiple paths, complete paths take precedence over partial paths. In the example above, https://marketplace.sample.com would return the product values "185242,97079" instead of the values specified for sample.com.

Was this page helpful?