productRecommendations returns empty array

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
Shopify Staff
Shopify Staff
195 23 33

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? Click Accept as Solution 

0 Likes
New Member
2 0 0

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

0 Likes
Shopify Staff
Shopify Staff
39 5 3

@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 Specialist @Shopify
0 Likes