1. jaak69
  2. RO CSVI
  3. Thursday, 31 August 2017
  4.  Subscribe via email
Hello,

I have ran into trouble the creating template for xml import:

The xml have nodes with same name. These nodes have different attributes. These nodes are in random order (this seems problem):

For example:

<datafields>
<data code="VEEB" content="1"/>
<data code="TOOTJA" content="Estko AS"/>
</datafields>


OR

<datafields>
<data code="TOOTJA" content="Estko AS"/>
<data code="VEEB" content="1"/>
</datafields>


I have watched the tutorial https://csvimproved.com/support/questions-and-answers/2956-import-xml-with-same-node-names, but in this example if I understand correctly that nodes with same name and different attributes must always be in same order.
Or is import from this XML is solvable using "Conditional" plugin?

Jaak
Accepted Answer Pending Moderation
Hello Jaak,
Ok, as per your XML you need to read manufacturer_name from the data node with attribute as code="TOOTJA" and i see that it can also come as a second node where the first node is for published field with code="VEEB".
So to solve this
1. Create a temporary String custom field in VirtueMart custom fields page, say we call it as manufacturer_test_name.
2. Update your available fields in CSVI so this test custom field will be available as an template field.
3. Add two template fields to your template, one is manufacturer_name and other is custom field manufacturer_test_name with both fields Your field set to datafields/data/content.
4. Add a conditional rule to check if value is equal to 1 then set Replace with >> Value from another field and Field/Value to manufacturer_test_name. Set this rule on manufacturer_name field in your template fields. This rule will check if manufacturer_name is 1 if the value is read from data node with code="VEEB" and replaces it with manufacturer_test_name which reads the data node with code="TOOTJA" which comes as second node in few cases.
5. Run the import.
Note that this import will also import values to custom field manufacturer_test_name but you can get rid of this custom field after your import is done as it is only for temporary use. Hope it is clear.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 1
Accepted Answer Pending Moderation
Hello,

Yes, you understand correctly what I have thought about random order. But unfortunately I really dont understand how the template will work in that case.

<datafields>
<data code="VEEB" content="1"/>in Virtuemart - attribute "content" value must go to field "published"
<data code="TOOTJA" content="Estko AS"/> in Virtuemart - attribute "content" value must go to field manufacturer_name
</datafields>


I attached full xml file

Jaak
Attachments (1)
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
Hello Jaak,
All I could understand from your example XML is that the nodes are interchanged. Is this what you are saying as random order? If yes, you can still use skip field to skip a node and its attribute as explained in the document. If its still not clear, can you post the your full import XML along with the screenshots on how you have your template fields setup?
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 3
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!