productRecommendations returns empty array

Highlighted
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
Highlighted
Shopify Staff
Shopify Staff
181 22 29

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
Highlighted
New Member
2 0 0

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

0 Likes
Highlighted
Shopify Staff
Shopify Staff
15 2 1

@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