In order to integrate with the Wix eCommerce platform, your business solution must provide a catalog of items for sale. In general, the catalog database can be hosted and managed wherever you prefer. In our example app, each site’s catalog database will live on the site itself.
A catalog database allows users to store information about the products they want to sell, and is central to any eCommerce app. For our example business solution, we’ll create a catalog of poems as a Wix data collection. When Wix users install our app, a copy of the collection is installed on their site. Wix users can then customize this collection to meet their site’s needs.
To create a collection in Blocks, we first need to connect our app to Blocks. We can do this by creating a Blocks widget from the app dashboard.
To add a widget, return to your app dashboard and go to extensions. Click on + Create Extension.
In the modal that opens, search for “widget” and find the Blocks widget extension. Click + Create on Blocks. This opens a new tab in the Blocks editor.
Note: If a window pops up prompting you to choose a template, you can close it.
In the lefthand column of the Blocks editor, you should now see something that looks like this:
We’ll rename and design our widget in the next step, but let’s first add the product catalog.
In the menu on the left, click CMS .
Under Your Collections, click Create Collection. A modal opens prompting you to name your app. Click Save & Continue to save your app name.
Next, Blocks prompts you to create an app namespace. Wix uses this namespace to identify your apps and create the collection ID. Click Next to continue. A new modal that looks like this appears:
The usual format of the namespace is @accountName
/appName
. We recommend accepting the default format. Click Next to continue.
Once you’ve set up your app name and namespace, a Create a collection modal appears offering you several options on how to set up your initial collection. Select the Start from scratch option and click Next.
Name your collection Poems and click Create. Blocks opens the CMS, where you can start editing the collection structure.
Click + Add Field to add columns to the collection. Add the following columns to the collection:
Field name | Field type |
---|---|
Title | text |
Price | text |
Description | text |
Main Product ID | text |
Variants | Javascript array |
Wix generates the field ID automatically when you name the field. Accept the default IDs.
Note: Once you save the field, you can’t change the field ID.
Now let’s add some sample data to get us started. Add the following items to the collection:
Title | Price | Description | Main Product ID | Variants |
Birthday Poem | 3 | Write a poem for someone’s birthday | 00003 | [ { "label": "For partner", "value": "v01" }, { "label": "For child", "value": "v02" }, { "label": "For friend", "value": "v03" }] |
Wedding Poem | 2 | Congratulate the bride or groom with a wedding poem | 00002 | [ { "label": "For bride", "value": "v01" }, { "label": "For groom", "value": "v02" }] |
Graduation Poem | 1 | Celebrate a new graduate with a graduation poem | 00001 | [ { "label": "For child", "value": "v01" }, { "label": "For other relative", "value": "v02" }] |
When a Wix user installs the app, they’ll receive these default values in their Poems collection.
This completes our catalog database setup. In the next article, we’ll connect our widget to the collection to allow site visitors to view the available poems.