I am using the woocommerce plugin of wordpress to build a shop.
It seems that the built-in CSV importer has no option to delete products which are not in the CSV file used to create / update the current products:
For example: If in my shop the products with the SKUs 'a1', 'b1' and 'c1' exist and the admin imports a product list with the SKUs 'a1', 'b1' the product with with the SKU 'c1' should be deleted / removed.
I reviewed the code of the product importer and the abstract importer and it seems that no such option exist.
Anyone knows howto solve that problem without installing yet another plugin ? Maybe a hook where the SKUs of the CSV file used to import are aggregated so I could load the existing SKUs from the database, compare with the SKUs in the CSV and delete them myself ?
Thanks for any ideas / assistance ! Kind Regards, m.
The way I'd probably go about is to use several hooks and transients:
Use this action to create a transient, which will store an array of all the IDs/SKUs in the file
Use this filter to add the ID to the array stored in the transient (making sure you return product_id)
Use this action to access (and delete) the transient. Now you have all the ID's/SKUs accessible to you and you can use them to find the ones that weren't included and delete them.
Personally I'd just use WP All Import
EDIT:
I got bored so I wrote the logic. It seems a bit inefficient to me but it should so the trick. UNTESTED.