Product Recommendations JavaScript SDK
📚 JavaScript library for retrieving and displaying product recommendations.
📦 Installation
This SDK can be pulled down from a CDN or installed as a module from NPM.
CDN
The latest version of the SDK is placed in the latest
directory.
<script src="https://sdk.magento-datasolutions.com/latest/index.js"></script>
Specific versions are also published on the CDN under their respective directories.
<script src="https://sdk.magento-datasolutions.com/v0.0.7/index.js"></script>
NPM
npm install @magento/recommendations-js-sdk
🥑 Usage
import {RecommendationsClient} from "@magento/recommendations-js-sdk"
const client = new RecommendationsClient({
instanceId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
storeId: 1,
storeViewId: 1,
})
client.registerUnit({
unitName: "more like what you bought but under 200",
filterQueryString: "base_price.1:<=200",
limit: 5,
rankerBlended: [
{
signal: "shopper_view_view",
key: "user_view_history",
boost: 100,
},
{
signal: "shopper_view_view",
key: "user_purchase_history",
boost: 10,
},
],
})
client.registerUnit({
unitName: "custom query sent",
limit: 5,
rankerBlended: [
{
signal: "query",
key: "categories:(159 OR 377)",
boost: 1,
},
],
})
const {status, data} = await client.fetchUnits({
currentSku: "134524",
cartSkus: ["140805", "140294"],
userViewHistorySkus: ["96039", "134103", "137685"],
userPurchaseHistorySkus: ["140307", "94079"],
})
❓ Questions
If you have questions or need help, there are a few ways you can get in touch.
📧 Email us at magento-product-recs@adobe.com
💬 Join us in the #p-rex channel
🐞 Open an issue in this repository