Page 1 of 1

CSV - Update records if the primary key matches

Posted: 2019-09-17 21:26
by khouse
Hi - There is a setting when importing a CSV that updates values of existing records, which is great. The problem is that you have to check it every time on import. Forgetting to check this value ignores values that are associated with existing keys, meaning basically nothing gets updated. Is there any way to default this to ON so my customer doesn't have issues with forgetting to check it?

Update table records if their primary key values match those in the CSV file.
If not checked, records in the CSV file having the same primary key values as those in the table will be ignored


Thank you - Kirk

Re: CSV - Update records if the primary key matches

Posted: 2019-09-18 19:19
by pbottcher
Hi,

you can edit the hooks/pageUploadCSV.php (remember that this will be overwritten if you regenerate you app).

serach for (around line 540 )

<?php echo $this->lang['update table records'] ; ?>

and update the line

<input type="checkbox" name="update_pk" id="update_pk" value="1" >

to

<input type="checkbox" name="update_pk" id="update_pk" value="1" checked>

Re: CSV - Update records if the primary key matches

Posted: 2019-09-18 20:10
by khouse
That did it, thanks so much! Wish it was a setting but I need to start avoiding the Overwrite All Files options :)

Only thing different is that I found the file in the admin folder. Thanks - Kirk

Re: CSV - Update records if the primary key matches

Posted: 2019-09-19 06:38
by pbottcher
Hi,

glad to see it works. And true it is in the admin folder not in the hooks. :-)