importX icon indicating copy to clipboard operation
importX copied to clipboard

Keep Existing Values on Update

Open doctorallen opened this issue 9 years ago • 4 comments

I'm using the latest version of importX, and when updating resources, it seems to remove all values that I don't pass in the CSV. I want to update field values, and keep any existing resource and template variables that I have not been passed the same.

I'm digging through the code trying to figure out where I can get this to work, but if someone has experience with doing this, or has done it before, that might save me some time.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

doctorallen avatar Mar 22 '16 19:03 doctorallen

I'm experiencing the same issue. Because TV values are not in the same table, it makes it difficult to do an update import because all TV values not included in CSV file get deleted.

CouponCodeSwap avatar Mar 25 '16 07:03 CouponCodeSwap

I've dug into it a bit, and I think that it's part of the MODX resource/update processor. I'm trying to figure out it's possible to prevent the replacement of all of these values using some option but so far I haven't found anything.

doctorallen avatar Mar 25 '16 14:03 doctorallen

Yeah, it definitely is the MODX resource/update processor. It queries all of the modx templateVariables, and either sets their new value to the value passed to the processor, or the default value, when in reality it should be looping over the passed TVs.

What I did was added a new processor that extends the existing processor and overrides the saveTemplateVariables function. Here is the code for the new processor. I put this in /core/model/mox/processors/resource/. I then set the importx.processor setting to updatenooverride. You still have to pass the alias, parent, and published settings in the CSV, because apparently those get overridden anyway and I didn't care to try and fix that as well.

Here is the example CSV I used:

id;alias;parent;published;tv1
2;test-alias;18;1;value1

doctorallen avatar Mar 25 '16 15:03 doctorallen

I'm reopening this as it is something I'd like to keep in mind for importx v2. :)

Mark-H avatar Mar 25 '16 17:03 Mark-H