The following article shows you the steps that were taken to make the upgrade and what to expect when you upgrade your projects to the new SDK.
The template includes common ecommerce marketplace functionality:
- Browse, search, and filter products for sale.
- Purchase a product using Stripe.
- Create your own product for sale (requires Cosmic login).
Steps to Upgrade
The steps we took to upgrade this template are:
- Updated the Bucket client configuration.
- Added an additional parameter to fetch the products ().
- Simplified the logic to add products.
You can see the pull request where each of the updates were made. Let's go over each step:
First, we removed the deprecated Cosmic NPM module:
2. Bucket configuration
Next, we updated the Bucket client configuration with the following code:
3. Object fetching
Then we added the parameter to the part of the code that handles the product fetching. Note: This is now required when fetching nested Object relationship data.
In this example, to fetch the nested data from categories along with the product data, which is connected to the product model by a Multi-Object relationship Metafield, we set a depth of .
4. Adding Objects
And lastly, we updated the way products are created as this has been dramatically simplified in the new API. Instead of a large array, you now have a concise object. (Less code FTW!)
I hope you found this guide instructive. Sign up to get started using Cosmic to power content for your websites and apps.