XML for a marketplace. Skip variants.

Highlighted

Hi,

I'm creating an xml page for a marketplace. It's mandatory include EAN for each variant but it's not available in all variants, so I tried this:

{% for variant in product.variants %}
    {% unless variant.barcode == empty %}
	<variation>
		<size>{{ variant.title }}</size>
		<qty>{{ variant.inventory_quantity }}</qty>
		<ean>{{ variant.barcode }}</ean>
	</variation>
    {% endunless %}
{% endfor %}

But it didn't work. Any idea?

The whole code: https://gist.github.com/Osotoro/f4db43a4f6636d159f3b079006922c86

 

 


0 Likes
Highlighted

I already find the mistake hehe. Here it is the right code:

{% for variant in product.variants %}
    {% unless variant.barcode == nil %}
	<variation>
		<size>{{ variant.title }}</size>
		<qty>{{ variant.inventory_quantity }}</qty>
		<ean>{{ variant.barcode }}</ean>
	</variation>
    {% endunless %}
{% endfor %}

 


0 Likes