To prevent the error “Invalid or duplicated SKU.” in the WooCommerce product import disable the mapping for the field “ID” by setting it to “Do not import” in the field mapping form of the 2nd step in the WooCommerce product import.
By attempting to import and map the (post) ID of your products by default, WooCommerce assumes that the database you’re exporting from and the database you’re importing into were the same databases at some point — which is most probably not the case in your case (and in 99% of all cases).
In order for the import to work without IDs, all of your products need to have a SKU. The WooCommerce product import falls back to using the SKUs of the products to map e.g. variations to their parent variable products.
Also, all of your SKUs need to be unique. SKUs of variations need to differ from their parents. To double-check that your product data is actually correct, execute the following database queries and ensure that they do not produce any results:
-- Most basic check within postmeta (must pass)
SELECT COUNT(p.ID) AS count, p.post_title
FROM wp_posts p
INNER JOIN wp_postmeta pm ON pm.post_id = p.ID AND pm.meta_key = '_sku'
GROUP BY pm.meta_value
HAVING count > 1;
-- More granular results with actual product IDs to check
SELECT p.ID, sku.meta_value AS sku, p.post_title, p.post_type
FROM wp_posts p
INNER JOIN wp_postmeta sku ON sku.post_id = p.ID AND sku.meta_key = '_sku'
INNER JOIN wp_postmeta dupe ON dupe.post_id <> sku.post_id AND dupe.meta_key = '_sku'
WHERE dupe.meta_value = sku.meta_value
GROUP BY p.ID;
Also make sure to use the action “Remove orphan product variations from database” in the Tools screen of the WooCommerce Settings page. The action has been introduced in a recent version and removes product variations whose parent variable products no longer exist in the database, but which still exist for unknown reasons (invisibly) in the database and cannot be seen or reached through the backend user interface.