hi i have two metafileds with type multiple values metafield no 1 select the multiple products like product1,product2,product3,product4 etc
then i show the title and link of that product.
metafield no 2 select the multiple images like image1,image2, image3,image4 etc
know i want that image 1 is attached with product 1 and image 2 is attached with product2 and so on.
how i can achieve this:
here is the code:
{% for recommended_product in product.metafields.custom.custom_product.value %}
{% for recommended_product in product.metafields.custom.custom_product.value %}
{{ recommended_product.title }}
{% assign product_index = forloop.index %}
{% for image in product.metafields.custom.custom_image.value %}
{% if forloop.index == product_index %}
{% endif %}
{% endfor %}
{% endfor %}
Which does not look like the most effective/elegant.
So here is the trick which worked for me (because for images preview_image points to themselves and map kinda converts the list to a normal indexed array)