Hi,
I have two questions. first one to understand how metafields are retrieved and second to see which code is faster.
On the product page, which one is correct for product.metafileds.global.material?
-
Shopify uses a for loop for all product metafeilds that contain global, then searches for material, then displays the result.
-
Shopify uses a for loop for all metafields that contain global.material, then displays the result.
-
Shopify retrieves product.metafileds.global.material without a for loop and displays the result.
I want to show product material, dimensions, etc. on the product page.
does it make sense to use metafields for each like:
{{ product.metafileds.global.material }}
{{ product.metafileds.global.diemensions }}
OR
use one JSON string metafield that contains all information
OR
use a for loop and if statement for tag in product.tags
{% for tag in product.tags %}
{% assign first_part = tag | split: ":" | first %}
{% if first_part == "material" %}
material{{ tag | split: ":" | last }}
{% elsif first_part == "dimensions" %}
dimensions
{{ tag | split: ":" | last }}
.
.
.
{% endif %}
{% endfor %}
I’ve read everywhere that tags are faster to retrieve than metafields, but since I’m calling a specific metafield rather than using a for loop and an if condition to get the information, isn’t a metafield faster to retrieve?
Thank you for taking the time to explain.