{% assign number_of_related_products_to_show = 4 %}
{% assign image_size = 'compact' %}
{% assign heading = 'Other fine products' %}
{% capture number_of_related_products_to_fetch %}{{ number_of_related_products_to_show | plus: 1 }}{% endcapture %}
{% if collection == null or collection.handle == 'frontpage' or collection.handle == 'all' %}
{% assign found_a_collection = false %}
{% for c in product.collections %}
{% if found_a_collection == false and c.handle != 'frontpage' and c.handle != 'all' and c.all_products_count > 1 %}
{% assign found_a_collection = true %}
{% assign collection = c %}
{% endif %}
{% endfor %}
{% endif %}
<div class="widget_related_products">
{% if collection and collection.products_count > 1 %}
<h3>{{ heading }}</h3>
<div class="widget_content">
<ul class="clearfix product_listing_main product_listing_related">
{% assign current_product_found = false %}
{% for prod in collection.products limit: number_of_related_products_to_fetch %}
{% if prod.title == product.title %}
{% assign current_product_found = true %}
{% else %}
{% unless current_product_found == false and forloop.last %}
<li class="wow col-sm-3 product product__{% cycle 'counter': '1','2','3','4' %}">
<div class="prod_inside clearfix">
<div class="product_img">
<a href="{{ prod.url | within: collection }}" title="{{ prod.title | escape }}"><img src="{{ prod.featured_image | product_img_url: image_size }}" alt="{{ prod.title | escape }}" /></a>
</div>
<div class="product_info">
<div class="product_price"><span class="money">{{ prod.price | money }}</span></div>
<div class="product_name"><a href="{{ prod.url }}" title="{{ prod.title | escape }}">{{ prod.title | truncate:20 }}</a></div>
</div>
</div>
</li>
{% endunless %}
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
</div>