🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
Integrations / Salesforce Commerce Cloud B2C

Is the Algolia cartridge compatible with SiteGenesis pipelines?

A SiteGenesis-based site can use both pipelines and controllers architectures simultaneously.

The Algolia cartridge uses controllers, but is fully compatible with your current pipeline architecture.

Is using the cartridge frontend mandatory?

The integration is split into four cartridges:

Cartridge Description
int_algolia Imports your product information from Salesforce B2C Commerce to Algolia.
bm_algolia Lets you monitor and configure Algolia indexing from your Business Manager.
int_algolia_controllers algolia_sg_changes Lets you implement Algolia InstantSearch on your SiteGenesis SFCC storefront.
int_algolia_sfra Lets you implement Algolia InstantSearch on your SFRA SFCC storefront.

The mandatory cartridges are int_algolia and bm_algolia. However, int_algolia_controllers and int_algolia_sfra are useful starting points if you’re willing to implement your frontend with InstantSearch.

Does the cartridge support multiple locales?

Yes. When assigning the Algolia cartridges to a site, they automatically support all the locales the site uses.

Does the cartridge support multiple currencies?

When assigning the Algolia cartridges to a site, they automatically support all the currencies the site uses.

If the cartridge is used on multiple sites will there be collisions?

The cartridge creates indices with a strict naming convention that prevents collisions between sites.

  • For products: ${hostname}__${site-id}__products__${locale}
  • For categories: ${hostname}__${site-id}__categories__${locale}

You can safely set up Algolia on any new site your create by assigning the int_algolia cartridge to it and running the indexing jobs, without worrying about name collisions.

To index data from multiple instances to the same index, you can configure the cartridge for Multi-instance indexing.

How can you improve indexing performance?

For tips on improving the performance of the indexing jobs, see Performance considerations.

How to index active data such as revenue data?

Indexing revenue metrics as an attribute in Algolia lets you use this data in your ranking formula.

By default, the Algolia cartridge for Salesforce B2C Commerce supports many product attributes. If you’d like to index an attribute that isn’t in the list of supported attributes, you can declare them directly, or define a custom function.

Declaring them directly

When you declare them directly, each attributes will appear at the top level of the Algolia product records.

  1. In the cartridge code, in the int_algolia/cartridge/scripts/algolia/lib/algoliaProductConfig.js file, declare each field with their attribute path:
    1
    2
    3
    4
    5
    6
    7
    
     var attributeConfig_v2 = {
         /* ... */
    
         revenueWeek: {
             attribute: 'activeData.revenueWeek',
             localized: false
         },
    
  2. In your Business Manager, go to Merchant Tools > Site Preferences > Custom Preferences > Algolia. Find Additional Product Attributes and add all fields, such as revenueWeek.
  3. Finally, reindex your data by going in Administration > Operations > Jobs and running the AlgoliaProductIndex_v2 job.

Using a custom function

Using a custom function permits you to regroup the various fields under a common top-level attribute, such as revenueData.

  1. In the cartridge code, in the int_algolia/cartridge/scripts/algolia/lib/algoliaProductConfig.js file, add a revenueData declaration
    1
    2
    3
    4
    5
    6
    
     var attributeConfig_v2 = {
         /* ... */
    
         revenueData: {
             localized: false
         },
    
  2. In the cartridge code, override the following code in the int_algolia/cartridge/scripts/algolia/model/algoliaLocalizedProduct.js file.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    
     // in file: int_algolia/cartridge/scripts/algolia/model/algoliaLocalizedProduct.js
    
    
     /**
      * Handler complex and calculated Product attributes
      */
     var aggregatedValueHandlers = {
         /* ... */
    
         revenueData: function (product) {
             var activeData = product.getActiveData();
             return {
                 quantityLast7Days: activeData.ordersWeek,
                 revenueLast7Days: activeData.revenueWeek,
                 quantityLast30Days: activeData.ordersMonth,
                 revenueLast30Days: activeData.revenuesMonth,
             };
         },
     };
    
  3. In your Business Manager, go to Merchant Tools > Site Preferences > Custom Preferences > Algolia. Find Additional Product Attributes and add revenueData.
  4. Finally, reindex your data by going in Administration > Operations > Jobs and running the AlgoliaProductIndex_v2 job.

Some attributes are protected. Don’t create or modify attributes with the same name.

Did you find this page helpful?