Updated SKU not recognized in some functions

On a website using WooCoommerce I have updated the SKU of some items programmatically, using.

$productid = wc_get_product_id_by_sku( $oldsku );
update_post_meta($productid,’_sku’,$newsku);

Thishas updated the codes for me, and in all the affected product tabs I see the new SKU correctly.

However, when I attempt a data update using WPAllImport where I use the SKU to locate the products to update, it updates the products with the old SKU. In the WPAllImport log I see the following for a product:

[11:34:22] Record #3
[11:34:22] ACTION: pmxi_before_post_import …
[11:34:22] Combine all data for post <span style="font-family: inherit; font-size: 0.8rem;">BENITO PÉREZ ARMAS.</span>…
[11:34:22] Find corresponding article among database for post <span style="font-family: inherit; font-size: 0.8rem;">BENITO PÉREZ ARMAS.</span>…
[11:34:22] Duplicate post was found for post <span style="font-family: inherit; font-size: 0.8rem;">BENITO PÉREZ ARMAS.</span>…
[11:34:22] Preserve date of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">BENITO PÉREZ ARMAS.</span>[11:34:22] Preserve status of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">BENITO PÉREZ ARMAS.</span>[11:34:22] Preserve content of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">BENITO PÉREZ ARMAS.</span>
[11:34:22] Preserve title of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] Preserve slug of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] Preserve excerpt of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] Preserve menu order of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] Preserve post parent of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] Preserve post type of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] Preserve comment status of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] Preserve ping status of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] Preserve post author of already existing article for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] Applying filter <span style="font-family: inherit; font-size: 0.8rem;">pmxi_article_data</span> for <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span>
[11:34:22] UPDATING <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span> Producto[11:34:24] Associate post <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span> with current import …
[11:34:24] WooCommerce ADD-ON:
[11:34:24] Property <span style="font-family: inherit; font-size: 0.8rem;">regular_price</span> updated with value <span style="font-family: inherit; font-size: 0.8rem;">5</span>
[11:34:24] Property <span style="font-family: inherit; font-size: 0.8rem;">stock_status</span> updated with value <span style="font-family: inherit; font-size: 0.8rem;">instock</span>
[11:34:24] Property <span style="font-family: inherit; font-size: 0.8rem;">stock_quantity</span> updated with value <span style="font-family: inherit; font-size: 0.8rem;">11</span>
[11:34:24] Property <span style="font-family: inherit; font-size: 0.8rem;">attributes</span> updated with value <span style="font-family: inherit; font-size: 0.8rem;">a:4:{i:0;O:20:"WC_Product_Attribute":1:{s:7:"*data";a:6:{s:2:"id";i:1;s:4:"name";s:8:"pa_autor";s:7:"options";a:1:{i:0;i:5973;}s:8:"position";i:1;s:7:"visible";b:1;s:9:"variation";b:1;}}i:1;O:20:"WC_Product_Attribute":1:{s:7:"*data";a:6:{s:2:"id";i:2;s:4:"name";s:12:"pa_categoria";s:7:"options";a:1:{i:0;i:1984;}s:8:"position";i:2;s:7:"visible";b:1;s:9:"variation";b:0;}}i:2;O:20:"WC_Product_Attribute":1:{s:7:"*data";a:6:{s:2:"id";i:0;s:4:"name";s:9:"Colación";s:7:"options";a:1:{i:0;s:5:"12 p.";}s:8:"position";i:5;s:7:"visible";b:1;s:9:"variation";b:0;}}i:3;O:20:"WC_Product_Attribute":1:{s:7:"*data";a:6:{s:2:"id";i:0;s:4:"name";s:21:"Fecha de publicación";s:7:"options";a:1:{i:0;s:4:"1956";}s:8:"position";i:10;s:7:"visible";b:1;s:9:"variation";b:0;}}}</span>
[11:34:24] ACF ADD-ON:
[11:34:24] IMAGES:
[11:34:24] UPDATED <span style="font-family: inherit; font-size: 0.8rem;">Vida y obra de doña Salomé Benítez Hernández (Extracto de un discurso)</span> <span style="font-family: inherit; font-size: 0.8rem;">Producto</span> (ID: 171990)
[11:34:26] ACTION: pmxi_saved_post
[11:34:26] ACTION: pmxi_after_post_import
[11:34:26] ---

“BENITO PÉREZ ARMAS” is the correct title for the product with the new SKU, but at a certain point it jumps to “Vida y obra de doña Salomé Benítez…”, which is the product that had that SKU before the change.

This problem does not only occur with WPAllImport: if in the ‘Products’ tab I do a search using one of the updated SKUs, the result shows the product that had that SKU previously, not the product that currently has it.

It’s as if somewhere internally WooCoomerce uses the product post identifier and ignores changes made to the SKU.

Any ideas on how I can resolve this?

  • This topic was modified 4 hours, 39 minutes ago by Ernesto r..

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer