From 17ee45307e4ee4a41fe9c5668ceba78b9a7696ab Mon Sep 17 00:00:00 2001 From: cond0r Date: Thu, 10 Jun 2021 16:20:10 +0300 Subject: [PATCH] Shuffle related products --- framework/shopify/api/operations/get-related-products.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/shopify/api/operations/get-related-products.ts b/framework/shopify/api/operations/get-related-products.ts index ea60e277a..d70f982cd 100644 --- a/framework/shopify/api/operations/get-related-products.ts +++ b/framework/shopify/api/operations/get-related-products.ts @@ -65,8 +65,9 @@ export default function getRelatedProductsOperation({ return { products: data.productRecommendations - ?.map((product) => normalizeProduct(product as ShopifyProduct)) - .splice(0, variables?.first || 4) ?? [], + ?.sort(() => 0.5 - Math.random()) + .splice(0, variables?.first || 4) + .map((product) => normalizeProduct(product as ShopifyProduct)) ?? [], } }