I did as you recommended to me.
I used the snippet that you specified and added it in step 3 to the “Functions Editor” section.
But the problem remained – WP all import did not delete the goods, but only made duplicates of all my goods. Products are still displayed in the catalog and on the site.
Let me remind you of the problem. I add external/affiliate products. The partner’s file is changed daily – new products are added, old ones are deleted, the price changes. I need to make sure that products that are not in the new file are not deleted, but become hidden, do not appear in the catalog, but participate in a Google search and are accessible via a direct link. And those products that are in the file have been updated prices.
I’m confused, please help me.
Thank.
Here is what I added in step 3 to the Functions Editor section:
<?php
function my_is_post_to_delete( $is_post_to_delete, $post_id, $import ) {
// Unless you want this code to execute for every import, check the import id
// if ( $import->id == 5 ) { ... }
if ( $product = wc_get_product( $post_id ) ) {
$product->set_catalog_visibility( 'hidden' );
$product->save();
}
return false;
}
add_filter( 'wp_all_import_is_post_to_delete', 'my_is_post_to_delete', 10, 3 );
?>
-
This reply was modified 4 years, 6 months ago by ilyapokrov.
-
This reply was modified 4 years, 6 months ago by ilyapokrov.