Skip to content

justindixon/RelatedProducts

Repository files navigation

Frequently Bought Together Products for Salesforce

Build codecov

Top 5 Products Frequently Bought Together

Unlocked Package - v1.0.0

Install Unlocked Package in a Sandbox Install Unlocked Package in Production


Demo Gif

Features

  1. Lightning Web Component showing frequently bought together products.
  2. Flow Action available to return the top 5 frequently bought products.
  3. Works only with Order Products for now.

Road Map

  1. Managed Package Version.
  2. Get Apex Docs To Work.
  3. Remove Content Assets from the Package.
  4. Enable For Opportunity Products.
  5. Enable for CPQ Quote Line Products.
  6. Units Tests for LWC.
  7. Enable additional file types (other than .jpq).
  8. Custom Object to hold the top 5 related products.
  9. Scheduled Batch Job to maintain the top 5 related products every night.
  10. Image resizing functionality.
  11. Completely custom build the carousel component. (Salesforce's is a bit limited, and hard to change).

Getting Started

After deployment, assign permission set Related Products Viewer to users. Provides access to view the lightning component.

Image Upload

Images need to be sized into the dimensions you require. Recommended is 240x320.

Images need to be uploaded as Content Assets.

Content Assets File Library Upload Button

The name of the Content Asset must match the Product Code that you want the image to display for.

File Details


Related Products Lightning Components: Quick Start


Related Products Flow Action: Quick Start

Flow Action

In your Flow you must input a single Product2 record Id. The top 5 most frequently bought products to the input Product will be returned as a list of Products.


Related Products Apex Class: Quick Start

You can call the class through Apex:

List<FrequentlyBoughtTogether.request> rqts = new List<FrequentlyBoughtTogether.request>();FrequentlyBoughtTogether.request rqt = new FrequentlyBoughtTogether.request();
rqt.Product2Id = product2Id;
rqts.add(rqt);
List<FrequentlyBoughtTogether.Result> rslts = FrequentlyBoughtTogether.freqProds(rqts);
List<Product2> rsltsProducts = rslts[0].frequentProducts;