SUNRISE sample data
Import sample data to your Project
Installing this sample data removes all existing data from your Project. Do not run it in a non-test Project.
When Projects are created, they are completely empty by default. To add sample data to your Project, you can import the SUNRISE data.
SUNRISE data includes Products, Categories, Customers, and other demonstration data that can assist developers and Merchant Center users with learning how commercetools Composable Commerce works.
Requirements
Importing the SUNRISE data requires you to create an API Client with commercetools Composable Commerce and a small import app that you can clone and build from GitHub.
Node.js must be installed to set up and run the import app.
Installation guide
Below are two guides: one suitable for developers and the other for non-developers. Following either guide will import the same SUNRISE data to your Project.
Developer guide
- Clone the SUNRISE data Git repository:
https://github.com/commercetools/commercetools-SUNRISE-data.git
This creates a folder named commercetools-SUNRISE-data. - Follow the instructions in our Getting started guide to create an API Client and download your environment variables (.env) file.
- Copy your
.env
file into commercetools-SUNRISE-data. - Open commercetools-SUNRISE-data in your terminal and use the command
npm install
to install required dependencies. - Use the command
npm run start
to start importing the SUNRISE data.
Non-developer guide
- Install Node.js on your computer.
- Go to the SUNRISE data GitHub page and click Code > Download ZIP. This downloads a file named commercetools-sunrise-data-master.zip.
- Extract the folder commercetools-sunrise-data-master from this file.
- Follow the instructions in our Getting started guide to create an API Client and download your environment variables (.env) file.
- Copy your
.env
file into commercetools-sunrise-data-master. - Open commercetools-sunrise-data-master in your terminal.
- In your terminal, use the command
npm install
. This installs software and plugins required for the import app to run (also known as "dependencies").
If you receive the error npm: command not found
or npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program.
then Node.js is not installed on your computer.
- Use the command
npm run start
. This runs the import app and starts importing the SUNRISE data.
Accessing your SUNRISE data
While the import app is running you can view the import progress in the terminal.
You do not have to wait for the process to complete before viewing the data in your Project. You can continue using the Merchant Center as normal during this time.
Once finished, you will have a complete sample data set ready to use.
More information
Further information for the SUNRISE data and extra commands for the import app can be found at GitHub.
How to handle the "A value is required for field 'baseId'." error when creating Products
After installing the SUNRISE data you may receive the following error when creating a Product:
{"statusCode": 400,"message": "A value is required for field 'baseId'.","errors": [{"code": "RequiredField","message": "A value is required for field 'baseId'.","field": "baseId"}]}
SUNRISE data includes a ProductType named main
with the required Attribute baseId
. This error is returned if a value for baseId
is not included with your ProductDraft.
Within the context of an example data set, baseId
can reference an external identifier for a Product. For example if Product information is stored/referenced in another system or database.
To handle this error, use one of the following actions.
Include a baseId value with your ProductDraft
This example ProductDraft demonstrates how to include a value for baseId
. Ensure that you change the highlighted Product Type id
and Attribute value
.
{"name": {"de": "German language product name","en": "English language product name"},"productType": {"id": "Replace with your ProductType id"},"slug": {"de": "german-language-slug","en": "english-language-slug"},"masterVariant": {"attributes": [{"name": "baseId","value": "Enter a value here"}]}}
Remove the baseId Attribute
If you have no need for the baseId
Attribute it can be removed using the API or in the Merchant Center.
Using the API
Attributes are removed using the Remove AttributeDefinition update action. The following example cURL command removes the baseId
Attribute from a specified Product Type.
Replace {region}, {projectKey}, and {productTypeID} with your Project's values and ${BEARER_TOKEN} with your access token.
curl -X POST https://api.{region}.commercetools.com/{projectKey}/product-types/{productTypeID} -H "Authorization: Bearer ${BEARER_TOKEN}" --data '{ "version": 1, "actions": [ { "action": "removeAttributeDefinition", "name": "baseId" } ] }'