woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.42k stars 10.77k forks source link

SKU duplication when using REST endpoint to create a product and adding the sku as meta data #29286

Open Geobusteni opened 3 years ago

Geobusteni commented 3 years ago

~ curl -X POST https://some.site/wp-json/wc/v3/products \ -u consumer_key:consumer_secret \ -H "Content-Type: application/json" \ -d '{ "name": "Product name", "type": "simple", "regular_price": "21.99", "description": "Testing sku duplication.", "meta_data": [ { "key": "_sku", "value": "1234567890" } ] }'

Using the code above, I was able to add multiple products with the same SKU. I am not sure if this is a bug or better said a future feature, but I think this should be prevented from happening in the future. Possibly using the wc_product_has_unique_sku() function at the right step would fix the issue.

roykho commented 3 years ago

Thank you for taking the time to report this bug, we really appreciate your help. I can reproduce it on my end.

We won’t be able to include this fix in the upcoming release due to the lower priority of this issue compared to others reported. We’re going to add it to our backlog so we can include it in our planning for one of our future releases.

vkwasinski commented 2 years ago

Actually I'm facing the oposite problem, I'm not able to create products because this logic flow always leads to the $this->error()

image