Problem with product-recommendations.liquid

Hello,

I would like to console.log all products listed in the recommendation section.

I have added the part but it doesn’t work:

{%- if section.settings.show_product_recommendations -%}
  {%- if recommendations.performed -%}
 
    {%- if recommendations.products_count > 0 -%}
 {% for product in recommendations.products %}
  

 
    {% endfor %}
      

        {%- if section.settings.heading != blank -%}
          

            ## {{ section.settings.heading | escape }}
          

        {%- endif -%}
        
          {%- for product in recommendations.products -%}    
            - {% include 'product-card-grid', max_height: 250, product: product, show_vendor: section.settings.show_vendor %}
            
          {%- endfor -%}
        

      

    {%- endif -%}
  {%- else  -%}
    

  
{%- endif -%}
{%- endif -%}

and any console.log there doesn’t work.

Do you have any idea how to do it?
Thanks

Hi @KrzysiekM

Hope you’re having a great day!

https://shopify.dev/themes/product-merchandising/recommendations/show-product-recommendations

Hi Michał,

Thank you so much for looking at my problem - it was worth being patient :slightly_smiling_face:

console.log({ 'recommendations': '{{ recommendations.products }}' });
      {%- for product in recommendations.products -%}

     {
       'name': '{{ product.title }}',         
        'id': '{{ product.id }}', 
        'price': '{{ product.price }}', 
        'brand': '{{ product.vendor }}', 
        'category': '{{ product.type }}', 
        'variant': '{{ product.compare_at_price}}',
        'sale': '{{product.compare_at_price_varies}}',
        'image': '{{ product | img_url }}',
    'link': '{{ page.url }}',
    'availablity': '{{ product.available }}',
    'collections': '{{ product.collections}}',
    'created': '{{ product.published_at }}',
    'tags': '{{ product.tags }}'
     },
       {% endfor %}

But unfortunately I have something like that and it doesn’t work:

And the console.log shows me “EmptyDrop” for recommendations.

Have you any idea why it is like that?

Thanks