Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 - -
- - - - - - -

Supporter timezone: Asia/Yerevan (GMT+04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Christopher Amirian 1 year, 5 months ago.

Assisted by: Christopher Amirian.

Author Posts
November 6, 2023 at 8:40 am #14735595

matthiasR-28

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.

November 6, 2023 at 2:14 pm #14738757

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

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.

Thanks.

November 6, 2023 at 2:16 pm #14738769

matthiasR-28

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.

November 6, 2023 at 2:35 pm #14738987

matthiasR-28

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?

November 7, 2023 at 6:32 pm #14751079

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

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.