Answers.Body: <p>Ok first thing take the s off relatedProduct because each loop is over <strong>one</strong> relatedProduct ;) - then you can do something like this:</p>
  
  <pre><code>{% for relatedProduct in product.relatedAccessories %}
     {{ relatedProduct.title }} - {{ relatedProduct.accessoryDescription }}
     Url: {{ relatedProduct.yourAssetHandle.first().url }}
  {% endfor %}
  </code></pre>
  
  <p>You should probably protect that by first checking <code>{% if relatedProduct.yourAssetHandle.first()|length %}</code> unless you can be completely certain you will have an asset (required field for example).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-04T15:43:34.333Z
Answers.Text: Perfect! That solved it. And a few other things for me to boot.
Answers.UserDisplayName: Wonko
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-04T21:36:21.877Z
Answers.Text: Glad to hear it - please accept it as an answer as I am shallow enough to desire points ;)
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-04T05:32:35.250Z
Answers.LastActivityDate: 2016-03-04T05:32:35.250Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>Folks:</p>
  
  <p>I'm using CraftCommerce. I have a main product and several accessories related to that product. Accessories have a title, description, price, and image.</p>
  
  <p>Now, I have no problem pulling the title and description for the related accessories using this:</p>
  
  <pre><code>    {% for relatedProducts in product.relatedAccessories %}
         {{ relatedProducts.title }} - {{ relatedProducts.accessoryDescription }}
      {% endfor %}
  </code></pre>
  
  <p>Where I've got a problem is pulling the related image. If I use <code>{{ asset.getUrl }}</code> it pulls the first image from the main product entry rather than the image in the related entry. I have tried <a href="https://craftcms.stackexchange.com/questions/4220/get-image-from-related-entries-asset-field">Get image from related entries asset field</a> and <a href="https://craftcms.stackexchange.com/questions/630/how-do-i-pull-related-entries-and-assets/640#640">How do I pull related entries and assets</a>? without success.</p>
  
  <p>Any assistance would be great.</p>
  
Tags: <relations><plugin-craftcommerce>
Title: Displaying image from related CraftCommerce entry
ThreadText: # Displaying image from related CraftCommerce entry
  
  (Asked by: username_0 on 2016-03-03)
  
  Folks:
  
  I'm using CraftCommerce. I have a main product and several accessories related to that product. Accessories have a title, description, price, and image.
  
  Now, I have no problem pulling the title and description for the related accessories using this:
  
  ```
      {% for relatedProducts in product.relatedAccessories %}
         {{ relatedProducts.title }} - {{ relatedProducts.accessoryDescription }}
      {% endfor %}
  
  ```
  
  Where I've got a problem is pulling the related image. If I use `{{ asset.getUrl }}` it pulls the first image from the main product entry rather than the image in the related entry. I have tried [Get image from related entries asset field](https://craftcms.stackexchange.com/questions/4220/get-image-from-related-entries-asset-field) and [How do I pull related entries and assets](https://craftcms.stackexchange.com/questions/630/how-do-i-pull-related-entries-and-assets/640#640)? without success.
  
  Any assistance would be great.
  
  **Tags:** relations, plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-03-04. Score: 2 | Accepted answer
  
  Ok first thing take the s off relatedProduct because each loop is over **one** relatedProduct ;) - then you can do something like this:
  
  ```
  {% for relatedProduct in product.relatedAccessories %}
     {{ relatedProduct.title }} - {{ relatedProduct.accessoryDescription }}
     Url: {{ relatedProduct.yourAssetHandle.first().url }}
  {% endfor %}
  
  ```
  
  You should probably protect that by first checking `{% if relatedProduct.yourAssetHandle.first()|length %}` unless you can be completely certain you will have an asset (required field for example).
  
  > **Comments:**
  > **username_0**: Perfect! That solved it. And a few other things for me to boot.  
  > **username_1**: Glad to hear it - please accept it as an answer as I am shallow enough to desire points ;)  
  
  ---
  
  