We are facing the issue that we cant update our products via api call because we got the error of unique sku.
I've found the problem and a solution, though I'm not sure how to prevent this from happening. The file 'woocommerce-multilingual/inc/class-wcml-products.php' adds a hook for 'wc_product_has_unique_sku' which triggers the 'check_product_sku' method. It searches for all products with a certain SKU. It then searches 'wp_icl_translations' to find a translation for each of these products. If one of these products has no value in wp_icl_translations it will fail and throw the 'invalid_product_sku' error.
Removing the product that has no translation will resolve the issue. I think that removing a language from WPML doesn't always remove the duplicate product it had created for that specific language.
If the issue is that there is a residual content after deleting a product please follow the steps below and see if it fixes the issue:
- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Go to "WordPress Dashboard > WPML > Support > Troubleshooting (link)".
- Click the "Set language information", "Assign translation status to duplicated content","Cleanup and optimize string tables", and "Fix post type assignment for translations" buttons.
Please Note: you need to have a backup of your website database before following the steps above.
Hi, the problem is not adding products. That works well.
The problem is with updating existing products. We have 3k products in 4 languages in our store but when we want to link the correct category to it we cant because of the unique sku error.
And our integration partner says if we remove the unique sku check in this file " woocommerce-multilingual/inc/class-wcml-products.php'" it will be solved. How can we safely remove this?
That check is not possible to remove as it is part of the code.
In the first question you have mentioned:
If one of these products has no value in wp_icl_translations it will fail and throw the 'invalid_product_sku' error
That is the normal behavior of WPML and if there is no entry in icl translations table that shows there was an issue with the website, maybe you edited or deleted products via code without the normal process of WordPress and that did not trigger proper WordPress hooks that WPML is using for translations.
I can ask the second-tier to see if there is any solution for this. but for now I'd appreciate it that you follow the steps I mentioned int he troubleshooting section after a backup and see if it fixes the issue.
Thanks.
The topic ‘[Closed] WPML Woocommerce api update issue’ is closed to new replies.