Hi @dadodd
The easiest way to do this would be to use manual record matching: https://www.wpallimport.com/documentation/recurring/manual-record-matching/. With this, existing posts will be updated with the data in your file, and new posts will be created, depending on these settings: https://d.pr/bVlioA (note: the delete option won’t be available when using manual record matching).
Alternatively, if you’re using a “New Items” import, you can utilize our wp_all_import_is_post_to_create hook: https://github.com/soflyy/wp-all-import-action-reference/blob/master/all-import/wp_all_import_is_post_to_create.php.
Here’s an example that will skip the record if the SKU already exists (based on the {sku[1]} element) in WooCommerce:
function my_is_post_to_create( $continue_import, $xml_node, $import_id ) {
global $wpdb;
$query = "SELECT <code>meta_value</code> FROM <code>" . $wpdb->prefix . "postmeta</code> WHERE <code>meta_key</code> = '_sku' AND <code>meta_value</code> = '" . $xml_node['sku'] . "'";
$results = $wpdb->get_results( $query );
return ( empty( $results ) ) ? true : false;
}
add_filter( 'wp_all_import_is_post_to_create', 'my_is_post_to_create', 10, 3 );