Liquid error: Could not find asset snippets/product-grid-item.

Tourist
32 0 2

Added related-products snippet and also {% include 'related-products' %} in product.liquid but getting an error showing where the products should be - Liquid error: Could not find asset snippets/product-grid-item. Any ideas?

 

Thanks.

 

My code in related-products

 

{% comment %}
  Number of related items per row,
  and number of rows.
{% endcomment %}

{% assign number_of_related_products_per_row = 4 %}
{% assign number_of_rows = 1 %}

{% comment %}
  Heading.
  Leave blank if you don't need one.
{% endcomment %}

{% assign heading = 'Other fine products' %}

{% comment %}
  Set either or both to true, if you want
  to limit yourself to items with same vendor, and/or type.
{% endcomment %}

{% assign same_vendor = false %}
{% assign same_type = false %}

{% comment %}
  Collections to ignore.
  Never pick related items from those.
{% endcomment %}

{% assign exclusions = 'frontpage,all' | split: ',' %}

{% comment %}
  Looking for a relevant collection.
{% endcomment %}

{% if product.metafields.c_f['Related Products'] %}
  {% assign collection = collections[product.metafields.c_f['Related Products']] %}
{% endif %}

{% assign found_a_collection = false %}
{% if collection and collection.all_products_count > 1 %}
  {% unless exclusions contains collection.handle %}
    {% assign found_a_collection = true %}
  {% endunless %}
{% endif %}
{% unless found_a_collection %}
  {% for c in product.collections %}
    {% unless exclusions contains c.handle or c.all_products_count < 2 %}
      {% assign found_a_collection = true %}
      {% assign collection = c %}
      {% break %}
    {% endunless %}
  {% endfor %}
{% endunless %}

{% comment %}
  If we have a relevant collection.
{% endcomment %}

{% if found_a_collection %}

  {% assign counter = 0 %}
  {% assign break_at = number_of_rows | times: number_of_related_products_per_row %}
  {% assign current_product = product %}

  {% case number_of_related_products_per_row %}
    {% when 1 %}
      {% assign grid_item_width = '' %}
    {% when 2 %}
      {% assign grid_item_width = 'large--one-half medium--one-half' %}
    {% when 3 %}
      {% assign grid_item_width = 'large--one-third medium--one-half' %}
    {% when 4 %}
      {% assign grid_item_width = 'large--one-quarter medium--one-third small--one-half' %}
    {% when 5 %}
      {% assign grid_item_width = 'large--one-fifth medium--one-third small--one-half' %}
    {% when 6 %}
      {% assign grid_item_width = 'large--one-sixth medium--one-third small--one-half' %}
    {% else %}
      {% assign grid_item_width = 'large--one-quarter medium--one-third small--one-half' %}
  {% endcase %}

  {% capture related_items %}
    {% for product in collection.products %}
      {% unless product.handle == current_product.handle %}
         {% unless same_vendor and current_product.vendor != product.vendor %}
           {% unless same_type and current_product.type != product.type %}
             {% include 'product-grid-item' %}
             {% assign counter = counter | plus: 1 %}
             {% if counter == break_at %}
               {% break %}
             {% endif %}
           {% endunless %}
        {% endunless %}
      {% endunless %}
    {% endfor %}
  {% endcapture %}

  {% assign related_items = related_items | trim %}

  {% unless related_items == blank %}

  <aside class="grid">
    <div class="grid__item">
      {% unless heading == blank %}
      <header class="section-header">
        <h2 class="section-header__title">{{ heading }}</h1>
      </header>
      {% endunless %}
      <div class="grid-uniform">
        {{ related_items }}
      </div>
    </div>
  </aside>

  {% endunless %}
     
{% endif %}

0 Likes
Shopify Expert
9811 92 1561

Hey Michael,

That error is very specific. It's telling you that the snippet file with the name of "product-grid-item.liquid" does not exist in your theme. You're referencing that snippet in the code even though it does not exist:

{% include 'product-grid-item' %}

Where did you grab the related products code from? From a different theme perhaps?

 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Tourist
32 0 2

https://gist.github.com/carolineschnapp/1002801 - The top post, I am using the Venture theme, is the whole code pretty much useless then?

 

Thanks.

0 Likes
New Member
17 0 0

Using the Minimal theme and I'm also getting the same error. "Liquid error: Could not find asset snippets/product-grid-item.liquid "

So if this theme does not have "product-grid-item" can I add it? What would the code be?

Cheers, Rob McJannett performanceimprovements.com
0 Likes
Tourist
13 0 1

Having the same issue - did you guys end up finding a solution??

0 Likes
Shopify Expert
9811 92 1561

@Charlie - my first reply in this thread still holds up.

That error is very specific. It's telling you that the snippet file with the name of "product-grid-item.liquid" does not exist in your theme. You're referencing that snippet in the code even though it does not exist:

If you're seeing an error like this it would mean 1 of 3 things:

  1. You've deleted a snippet from the theme that you shouldn't have
  2. You've copied code from a different theme that uses different names for snippets (or you've not copied over all the snippets needed)
  3. You've added a typo into the {% include %} tag

The solution would come from providing extra details on how you got to the point of seeing the error. AKA, what recent changes have you made?

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Tourist
13 0 1

Thanks Jason! I figured as such but not sure which snippet I should reference instead within my theme - I'm using the Venture theme. I followed the instructions from this guide precicesly: https://help.shopify.com/themes/customization/products/recommend-related-products.

My website is www.plantfacedclothing.com if you're able to see what snippet I should be referencing from there.

0 Likes
Tourist
13 0 1

Changing the snippet for "product-grid-item" to "product-card" makes the items show up now, but they are stacked on top of each other in wide strips rather than in a grid.

0 Likes
Tourist
13 0 1

I found the solution, everyone! Code adjusted for Venture here: https://gist.github.com/hhayrapetyan/bb697ae50169da8ba500

1 Like
Shopify Expert
9811 92 1561

Awesome to see you posting an update - that will be really helpful for anyone else with the same theme. Glad to hear you've got a solution!

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes