What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: {{ recommendations.products_count }} always 0 on product page

{{ recommendations.products_count }} always 0 on product page

twilson90
Shopify Partner
32 0 23

Trying to implement a recommendations section for my store, I just can't get the recommendations object to populate with products.

 

Tried installing the 'Search & Discovery' app, I can see it auto generates 10 recommendations for each product in my store in the admin, but on the front-end I cannot get it to work.

 

Any ideas?

Replies 5 (5)

PageFly-Oliver
Shopify Partner
878 190 184

Hi @twilson90 ,

I think you can try using the code lowercase key work 

recommendations.products_count

 

Hope my solution works perfectly for you!

Best regards,

Oliver | PageFly

Please let me know if it works by giving it a Like or marking it as a solution!


PageFly - #1 Page Builder for Shopify merchants.


All features are available from Free plan. Live Chat Support is available 24/7.

twilson90
Shopify Partner
32 0 23

What I wrote was originally lowercase but Shopify community for some reason capitalizes post titles.

PageFly-Oliver
Shopify Partner
878 190 184

Can you share the source code so I can try it?

Please let me know if it works by giving it a Like or marking it as a solution!


PageFly - #1 Page Builder for Shopify merchants.


All features are available from Free plan. Live Chat Support is available 24/7.

twilson90
Shopify Partner
32 0 23

There's nothing besides what's in the title. On the product page I just put:

 

{{ recommendations.products_count }} 

And it's always 0, and the recommendations.products property is always empty.

This isn't a liquid issue, but something in my shopify setup that for some reason denies the usage of the recommendations object.

Shiref
Shopify Partner
11 0 1

because this object isn’t populated when the section is initially rendered, so you need to use JavaScript to retrieve the populated section content through the section response of the Product Recommendations API.

 

Source: https://shopify.dev/docs/themes/product-merchandising/recommendations/complementary-products#impleme...