Skip to content

Latest commit

 

History

History
89 lines (63 loc) · 2.54 KB

README.md

File metadata and controls

89 lines (63 loc) · 2.54 KB

Swell (Ecommerce) / Algolia Integration

This Module is a deep integration with Swell and Algolia allowing you to rank, facet and replicate

This module deploys to AWS Lambda

alt text

alt text

Install

You'll need serverless to run this and a AWS account or other provider

npm install -g serverless

Config

set a .env file

SWELL_STORE_ID=***
SWELL_SECRET_KEY=***
ALGOLIA_INDEX=swell_products
ALGOLIA_APP_ID=***
ALGOLIA_ADMIN_API_KEY=***

Algolia Config

Update the Algolia config (algolia.config.json) to what you need for your project.

Field Description
defaultRanking The ranking of your default index ALGOLIA_INDEX
rankings The individual rankings for using sort, will create a seperate replica per ranking
searchableAttributes Algolia searchable Attributes
attributesForFaceting Algolia Facetable Attributes
{
  "defaultRanking": ["desc(name)"],
  "rankings": [
    {
      "suffix": "price_desc",
      "ranking": [
        "desc(price)"
      ]
    },
    {
      "suffix": "price_asc",
      "ranking": [
        "desc(price)"
      ]
    }
  ],
  "searchableAttributes": ["name"],
  "attributesForFaceting": ["attribute.brand", "categories"]
}

Quick Start

The commands below will deploy the serverless function to AWS then create the indexes

sls deploy
sls invoke --function init
sls invoke --function reindex

sls invoke --function init will create the replicas based on your algolia.config.json sls invoke --function reindex will pull all the products into Algolia

Install webhooks on Swell

Developer > Webhooks > Add Webhook

And create a webhook as so:

Screen Shot 2021-12-04 at 8 26 20 pm

Replace my-serverless-domain with your cloudfront, or route53 domain generated from serverless on deploy

Replace stage with your environment stage so something like dev or prod