Hi David
Finally in the process of setting up, and cannot find this issue covered in the forum so far.
I wish to create additional fields on registration from attribute details in the XML file. I understand how to map an extra import field for a named field, e.g. "SKU", but I need to map a field based on the value entry of a XML detail field.
Easier to explain with an example:
XML Entry:
<details>
<detail>
<name>Brand</name>
<value>Casio</value>
</detail>
<detail>
<name>Colour</name>
<value>White</value>
</detail>
</details>
field = Sample Data
Details/Detail/Name = Brand
Details/Detail/Value = Casio
Details/Detail/Name@ = Colour
Details/Detail/Value@ = White
And subsequent details are name@1, name@2, etc.
The problem is some records have different levels of detail, so the "Colour" detail in the example may be in the field "name@" on some products and "name@1" on others, etc.
So I need to map the value "white" based on the detail name "Colour" and not the field name itself.
Please can you point me in the right direction :)
Thanks David.
Example feed: {link saved}
Cheers
Gerard
Thanks Gerrard,
Here's a tidy way to handle that style of supplementary data. For each custom field that you want to import but is represented in this way, register the blank field "DETAILS".
After registration, click Filters, and add Text After filters to each of your custom fields mapped to "DETAILS". In the text box on the configuration page for each filter, enter the value that you wish to match, exactly as it appears in the sample data, for example "Colour" (without the quotes).
Next, edit includes/admin.php and look for the following comment at line 231:
/* drop record if set by user filters filters */
...and immediately before that point, insert the following new code:
$details = array();
$i=0;
$p="";
while(1) {
if ($i) $p = "@".$i;
$k = "DETAILS/DETAIL/NAME".$p;
$v = "DETAILS/DETAIL/VALUE".$p;
if (!isset($record[$k])) break;
$details[$record[$k]] = $record[$v];
$i++;
}
foreach($config_fieldSet as $field => $v)
{
if ($admin_importFeed["field_".$field] == "DETAILS")
{
$importRecord[$field] = $details[$importRecord[$field]];
}
}
Cheers,
David.
--
PriceTapestry.com
Hello GPR, and welcome to the forum!
Sure I can - i've seen it all when it comes to XML!
In situations like this, if you could let me know the URL of your installation, and the filename of an example feed containing this style of markup (i'll remove the details before publishing your reply), I'll download the feed to my test server and work out how to deal with this format for you!
Cheers,
David.
--
PriceTapestry.com