This script allows easier transition from Magento to Crystallize. It handles importing of product and folder structure, while respecting product association to multiple folders. You can use this script to import the product catalogue from Magento to Crystallize periodically or use it to migrate to Crystallize.
Crystallize is a fast GraphQL based PIM to build headless eCommerce solutions. If you are migrating from Magento to Crystallize you should check out the Open Source React eCommerce Boilerplate.
If you stumbled upon this script check out the concepts of how to build fast React eCommerce using Crystallize.
The import script requires a number of environment variables to set up before running, like your Magento integration and Crystallize keys. These can be passed as arguments when running the script or be setup in the lib/config.js file.
Since importing a catalogue might be a very time consuming process, we have set up a single SKU import script command. This gives you the ability to test things like, creating a product shape that fits your information architecture, and start building bottom to top.
Import a single product by running:
SKU=*your_sku* yarn run single
Import the entire catalogue by running:
yarn run import
From SKUs to content, every case can vary in structure and logic and you can tweak the script to fit these needs. The core logic of the script is focused around:
- lib/helpers/map-product.js
- lib/helpers/map-folder.js
- lib/crystallize/mutations
- lib/crystallize/index.js
The import script follows Crystallize’s modern topic-based approach. Multiple categories can be associated to products by creating them as topics. Starting from top to bottom, the script will create a tree topic-structure and tag products with topics based on naming.
These can be specified as arguments in index.js file. The script behaviour can be altered in these files:
-
lib/helpers/category-filter
-
lib/crystallize/index.js (createTopics)
* Notice that by default the topics generated by the categories passed as arguments will not be included in the catalogue structure.