Hi David,
I hope you can help with this one. I am trying to put some code in admin.php for manipulating records at import. Now, I'm seeing some strange behaviour whereby if I try and set one field to a particular value, any other blank fields are also assigned this value for some reason. i.e. if I use this code:
if (trim($record["FIELDS/FIELD/NAME@1"]) === "size")
{
$record[$admin_importFeed["field_B"]] = $record["FIELDS/FIELD/VALUE@1"];
}
I've come across this before and it's stumped me and previously I've had to create separate variables to deal with it. i.e.
$fieldB = $record["FIELDS/FIELD/VALUE@1"];
Cheers.
Keeop
Hi David,
I'm really trying to avoid doing it that way as I may need to work on the $record later on and I can then use a generic solution for any field. I have tried using ISSETs but to no avail either:
$record[$admin_importFeed["field_B"]] = (isset($record["FIELDS/FIELD/VALUE@1"])?trim($record["FIELDS/FIELD/VALUE@1"]):"");
Cheers.
Keeop
Hi Keeop,
One option would be to create a "virtual" field for it; so before your code above, try something like:
if (!$admin_importFeed["field_B"])
{
$admin_importFeed["field_B"] = "%FIELDB%";
}
...and that will prevent overwriting the null ("") value...
Hope this helps!
Cheers,
David.
Hi David,
I'm not quite sure how it works, but it most certainly does! Thanks a lot for that.
Cheers.
Keeop
Ah, spoke too soon! It doesn't seem to be importing most of the records any more. Any ideas as to why?
Cheers.
Keeop
Hi Keeop,
If $admin_importFeed["field_B"] is empty then it will be updating the null element of $record; which is why every field that has not been assigned a record will take on the value of $record["FIELDS/FIELD/VALUE@1"]. Assigning a separate value would be the best aproach in this case...
Cheers,
David.