import only one record

Closed

Import WP Pro Updated 3 weeks ago 17 Replies

Kris asked 3 weeks ago on January 29, 2025 at 6:25 pm

Hi

I already bought your plugin, worked perfect. But now in another site, some strange behavior. I have an acf-type and some fields. I mapped them correctly, also having a unique identifier. I have a .csvfile and import is running. But there is only 1 record created. And this is always the last record from the file.

Problem 2 is that the date field is always 01/01/1970 but in the preview of the date fields, the date is shown correct.

What goes wrong?

KO

Kris replied privately

3 weeks ago on January 29, 2025 at 6:42 pm

KO

Kris replied privately

3 weeks ago on January 29, 2025 at 6:43 pm

J

James replied Support Agent

3 weeks ago on January 29, 2025 at 7:44 pm

Are you able to Delete the record with ID: 200 , and remove it from the trash / bin, then retry the import? as the history shows it is searching for the correct value.

If that fails are you able to goto Settings / Tools > Enable Debug Mode, and view and attach the importer log?

In regards to dates, wordpress expects dates to be in Y-m-d H:i:s format, otherwise it gets the default database date of 1970, to solve this issue you could create a custom method to transform your date into the correct format? (if you need help with this let me know)

James

KO

Kris replied privately

3 weeks ago on January 29, 2025 at 7:56 pm

J

James replied Support Agent

3 weeks ago on January 29, 2025 at 8:04 pm

If you deleted the record id 200 and removed it from the trash, it should not still be there.

But if the id 200 is still shown in your history if you re-run the importer then it has not been removed.

Is there any chance you can provide me with temporary access to the site?

KO

Kris replied privately

3 weeks ago on January 29, 2025 at 8:07 pm

J

James replied privately Support Agent

3 weeks ago on January 29, 2025 at 8:12 pm

KO

Kris replied privately

3 weeks ago on January 29, 2025 at 8:16 pm

J

James replied Support Agent

3 weeks ago on January 29, 2025 at 8:29 pm

Thanks,

I have tried on your website and i can see what you are talking about, from the debug log i can see that the importer is telling wordpress to search for a record with the correct reference.

I then tried creating a second record in the "Leden" post type, without setting a licentienummer, then changed the unique identifier to be Template field: licentienummer, this returned the error:

Record is not unique: licentienummer, Matching Ids: (210, 208).

This suggests that your theme or a plugin might be overriding the WP_Query via a filter or action, modifying it causing this issue.

I then tested your importer and acf fields locally and the importer worked as expected.

My advice to debug this issue would be to backup your website database and files, then enable a default wordpress theme such as twentytwentyfour , and disable all plugins except for acf and the ImportWP Plugins, and then re-run the importer to see if the conflict still exists.

If it doesnt then it would be a case of re enabling themes and plugins until the issue appears again.

James

KO

Kris replied privately

3 weeks ago on January 30, 2025 at 2:24 pm

J

James replied Support Agent

3 weeks ago on January 30, 2025 at 2:31 pm

To convert dd/mm/yyyy e.g. 13/12/2024

the following function would convert this to: 2024-12-13

function iwphd1045_convert_date($input = ''){
    $date = date_create_from_format('d/m/Y', $input);
    return $date->format('Y-m-d');
}

To use this code you would need to add it to your website code or via a plugin: https://www.importwp.com/docs/using-code-snippets-in-wordpress/

Then in your importer you would use it as follows:

{1}

would turn into

[iwphd1045_convert_date("{1}")]

James

KO

Kris replied privately

3 weeks ago on January 30, 2025 at 2:48 pm

J

James replied Support Agent

3 weeks ago on January 30, 2025 at 2:52 pm

Try this, that error just means the date was invalid (is this example accessible from the previous details?):

function iwphd1045_convert_date($input = ''){
    $date = date_create_from_format('d/m/Y', $input);
    return $date ? $date->format('Y-m-d H:i:s') : '';
}
KO

Kris replied privately

3 weeks ago on January 30, 2025 at 3:31 pm

J

James replied privately Support Agent

3 weeks ago on January 30, 2025 at 3:43 pm

KO

Kris replied

3 weeks ago on January 30, 2025 at 3:52 pm

ok, missed that one.

Nice, everything works perfect. Thx for all the help.

Kris

J

James replied Support Agent

3 weeks ago on January 30, 2025 at 4:08 pm

Glad its working i will close the ticket.

Never seen that before but i do know sometimes when you copy and paste double or single quotes sometimes you get the fancy display versions of them which are not actually quotes.