Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate products with identical SKUs created via API #35

Open
rafal-sokolowski opened this issue Sep 18, 2019 · 1 comment
Labels

Comments

@rafal-sokolowski
Copy link

@rafal-sokolowski rafal-sokolowski commented Sep 18, 2019

Description of the problem
The syncing system sends requests to /wp-json/wc/v3/products/batch endpoint. It usually creates concurrent connections to the WooCommerce API. Sometimes, it happens that if two or more requests contain information about the same product and they run at the same time we end up with multiple products created having identical SKUs.

Steps to reproduce

curl -X POST \
  https://shop.test/wp-json/wc/v3/products/batch \
  -H 'Authorization: Basic Y2tfZWExNmNmNzVkZjkyMWM4YWZmYmI2MjAxYmZiMjU0ODAwNjNhYzk2MTpjc183MDAzOGMxNTRiZWVlYmEyMTU2ZmQ4MGQ2NWE5ZmM1NzcyMGY5M2Mz' \
  -H 'Content-Type: application/json' \
  -d '{
    "create": [
        {
            "name": "Unique SKU product",
            "type": "simple",
            "sku": 12345
        }
    ]
}' -k & curl -X POST \
  https://shop.test/wp-json/wc/v3/products/batch \
  -H 'Authorization: Basic Y2tfZWExNmNmNzVkZjkyMWM4YWZmYmI2MjAxYmZiMjU0ODAwNjNhYzk2MTpjc183MDAzOGMxNTRiZWVlYmEyMTU2ZmQ4MGQ2NWE5ZmM1NzcyMGY5M2Mz' \
  -H 'Content-Type: application/json' \
  -d '{
    "create": [
        {
            "name": "Unique SKU product",
            "type": "simple",
            "sku": 12345
        }
    ]
}' -k

Expected behavior
By default, it should not be possible to add a new product with an existing SKU.

Isolating the problem (mark completed items with an [x]):

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active, or Storefront.
  • I can reproduce this bug consistently using the steps above.

WordPress Environment

``` Serverinfo: Apache/2.4.41 (Unix) OpenSSL/1.0.2s PHP/7.2.22 PHP version: 7.2.22 MySQL version: 5.5.5-10.4.6-MariaDB WooCommerce version: 3.6.4 WordPress version: 5.2.3 ```
@claudiosanches claudiosanches transferred this issue from woocommerce/woocommerce Oct 1, 2019
@issue-label-bot issue-label-bot bot added the type: bug label Oct 1, 2019
@issue-label-bot

This comment has been minimized.

Copy link

@issue-label-bot issue-label-bot bot commented Oct 1, 2019

Issue-Label Bot is automatically applying the label type: bug to this issue, with a confidence of 0.98. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.