Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
764 views
in Technique[技术] by (71.8m points)

liquid - Map Array Filter on Shopify

I'm trying to add a value of metafield in XML Feed using omegashoppingfeed.

Using {% assign test123 = product.meta_fields %} and after that in the feed i'm using

 <product>
              <oeo15>{{ test123 }}</oeo15>
              <id>{{product.id}}</id>
    </product>

The result is the following

<oeo15>map[global:map[%ce%b1%ce%b9%cf%83%ce%b8%ce%b7:Επιταχυνσι?μετρο Καρδιακ?ν Παλμ?ν Παρακολο?θηση ?πνου Βηματ?μετρο %ce%bf%ce%b8%cf%8c%ce%bd%ce%b7:Ναι %cf%83%cf%85%ce%bc%ce%b2%ce%b1:Android, iOS %cf%84%cf%8d%cf%80%ce%bf%cf%82:Band %cf%87%cf%81%cf%8e%ce%bc%ce%b1:Μα?ρο description_tag:Activity-Tracker-XIAOMI-Mi-Band-4-Black title_tag:Activity Tracker XIAOMI Mi Band 4 Black weight:1.00000000 Αισθητ?ρε?:Επιταχυνσι?μετρο Καρδιακ?ν Παλμ?ν Παρακολο?θηση ?πνου Βηματ?μετρο Οθ?νη_2nd:Ναι Τ?πο?_2nd:Band Χρ?μα_2nd:Μα?ρο] mc-facebook:map[google_product_category:1604] skroutzfeed:map[mpn:XMSH07HM]]</oeo15>

How can I get the value of the metafield called mpn?

question from:https://stackoverflow.com/questions/65940568/map-array-filter-on-shopify

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to add the namespace as well:

product.metafields.<namespace>.mpn

The standard way to access product metafields is:

product.metafields.<namespace>.<key>

or

product.metafields.<namespace>['<key>']

Example:

{% assign instructions = product.metafields.instructions %}
{% assign key = 'Wash' %}
<ul>
  <li>Wash: {{ instructions[key] }}</li>
  <li>Wash: {{ instructions['Wash'] }}</li>
  <li>Wash: {{ instructions.Wash }}</li>
</ul>

More here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...