productRecommendations returns empty array

CaribouCode
New Member
2 0 0

I have a new shopify account and have added 27 products split between 2 collections.

When I run a query to get productRecommendations using a productId through the Storefront API, I get an empty array back. Having read the docs about how the recommendation logic works, it should fallback to returning products in the same collection, which it doesn't appear to be doing.

My query looks like this

 

const GET_PRODUCT_RECOMMENDATIONS = gql`
  query($productId: ID!) {
    productRecommendations(productId: $productId) {
      id
      title
    }
  }
`;

 

Execution is:

 

const { data } = await apolloClient.query({
  query: GET_PRODUCT_RECOMMENDATIONS,
  variables: {
    productId: 'xxxxxx',
  },
});

 

And the result is data.productRecommendations is an empty array. Note I pass in a productId that belongs to a product in a collection.

Is this a bug in the API?

0 Likes
Kevin_A
Shopify Staff
Shopify Staff
311 42 54

Hey @CaribouCode 

Can you provide the product ID you used for this? 

Kevin_A | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
CaribouCode
New Member
2 0 0

@Kevin_A An example product ID I am having this issue with is: Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU5NTkzODgxMDI4NTY=

0 Likes
_JCC_
Shopify Staff
Shopify Staff
158 21 27

@CaribouCode ,

I've had a chance to take a further look at this issue, and unfortunately the productRecommendations query only works as expected on Shopify plans higher than lite.

I've recorded the issue on your behalf to help influence product development in the StoreFront API. 

Regards,

John

 

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes