title: Related Products not showing correctly
body: <p>I am trying to generate related products in one of my shopify store, its showing on some products but mostly not, what I want is, display related product first by matching vendor/brand, if not found then show the products of same category:</p>
  
  <p>Can anybody please suggest how to handle this?</p>
  
  <pre><code>&lt;div class="related-products row"&gt;
  {% assign vendor = product.vendor %}
  {% assign vendor_handle = vendor | handleize %}
  
  {% assign handle = product.handle %}
  &lt;h4 style="text-align:left;"&gt;More in this collection&lt;/h4&gt;
  {% assign counter = '' %}
  {% for product in collections[vendor_handle].all_products %}
    {% if vendor == product.vendor and counter.size &lt; 4 and handle != product.handle %}
    {% capture temp %}{{ counter }}*{% endcapture %}
    {% assign counter = temp %}
    &lt;div class="col-md-3 col-sm-3 col-xs-12"&gt;
      &lt;div class="reveal"&gt;
        &lt;a href="{{ product.url | within: collection }}" title="{{ product.title }}"&gt;
          &lt;img src="{{ product.images.first | product_img_url: 'large' }}" class="img-responsive" alt="{{ product.title }}" /&gt;
        &lt;/a&gt;
      &lt;/div&gt;
      &lt;a href="{{ prod.url | within: collection }}" title="{{ prod.title | escape }}"&gt;
          {{ product.title | escape }}
      &lt;/a&gt;
    &lt;/div&gt;
    {% endif %} 
  {% endfor %}
  &lt;/div&gt;
  </code></pre>