This example demonstrates how you can import products, brands, categories, collections, orders and/or customers to Algolia from Moltin through a Command Line Interface (CLI).
When running this example locally you'll want to be careful not to exceed you Algolia limits for catalog size.
Clone the repository:
git clone git@github.com:uniquelyparticular/import-moltin-to-algolia.git
Install dependencies with Yarn (or NPM)
cd import-moltin-to-algolia
yarn
In this example we will import data to Algolia. You will need an account an account to continue.
Once you've signed up to Algolia, create a new app and give it a name.
Next head to the API keys
section and make a note of your Application ID
and Admin API Key
, we will need these next.
You will want to create an .env
inside the directory /import-moltin-to-algolia
containing all the keys for the below:
MOLTIN_CLIENT_ID=
MOLTIN_CLIENT_SECRET=
MOLTIN_AGOLIA_INDICES=
ALGOLIA_APP_ID=
ALGOLIA_API_KEY=
MOLTIN_AGOLIA_INDICES
is optional as they can also be passed and/or overriden on the command line but it is used to restrict which Moltin objects to generate Algolia indices for (ie. products,brands,categories,collections,orders,customers
).
MOLTIN_CLIENT_ID
and MOLTIN_CLIENT_SECRET
are available in your Moltin Dashboard.
NOTE: make sure that you've installed the dependencies in Step 1.
Ensure that the executable has proper permissions to run from the command line.
chmod +x ./bin/moltin-to-algolia
Execute the import command to import ALL of your products, brands, categories, collections, orders and customers into Algolia
NOTE: you can also run the import command with any subset of those entities to limit what is imported
Full import (run the following command):
./bin/moltin-to-algolia import
Partial import (run the following command specifying a comma seperated list w/o spaces of entities to index):
./bin/moltin-to-algolia import products,brands
NOTE: available entities to import: products,brands,categories,collections,orders,customers
Go to the app you've set up in Algolia's Dashboard (https://www.algolia.com/apps/[ALGOLIA_APP_ID]) and check the new indexes created. There should be one index created for each entity type imported.
You can then configure any specific Configuration data for that Index in Algolia to help further optimize search.
NOTE: it is reccomended that you adjust the Searchable Attribute Configuration for each index to only seach on specific fields.
That's it...have fun and take a look at Alogolia's InstantSearch from here to build an amazing front end for your indices!
There is separate repository/package you can use to set up automated ongoing index updates from Moltin to Algolia using Moltin's Observable WebHooks and is fully compatible with the indices generated above. To set up the webhooks to automate create/update/delete entries in your index, please follow the instructions at the following:
https://github.com/uniquelyparticular/sync-moltin-to-algolia
Contact Adam Grohs @ Particular. for any questions.