The SKU (xxxxxx) you are trying to insert is already under processing
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 15/100
Research direction
No repository file or test is named. Start at the shown wcapi.get, wcapi.put, and wcapi.post calls for the products endpoint and reproduce the WooCommerce response with the CSV row; done would require a confirmed repository-scoped change and a test, neither of which this report specifies.
Written by the indexing model from the issue text.
Description
Hi guys, I have a problem to create new product when import csv file, receive this erros e in log to woocommerce.
{
"error": "woocommerce_rest_product_not_created",
"code": 400
}
my code
import time
import threading
import pandas as pd
from woocommerce import API
wcapi = API(
url="https://xxxx",
consumer_key="AAA",
consumer_secret="AAA",
wp_api=True,
timeout=60,
version="wc/v3"
)
df = pd.read_csv("_@@_teste1produto.csv")
for index, row in df.iterrows():
data = {
'name': row['name'],
'type': row['type'],
'sku': str(row['isbn']),
'regular_price': str(row['price']),
'description': row['description'],
'categories': [{'name': row['categories']}],
'images': [{'src': row['image']}],
'status': row['status'],
'catalog_visibility': row['visibility'],
'tax_status': row['tax_status'],
'weight': str(row['weight']),
'dimensions': {
'length': str(row['length']),
'width': str(row['width']),
'height': str(row['height'])
},
'manage_stock': True,
'stock_quantity': int(row['stock']),
}
product_lock = threading.Lock()
def create_or_update_product(wcapi, row, data):
max_retries = 3
retry_delay = 5
with product_lock:
for attempt in range(max_retries):
produtos_existentes = wcapi.get("products", params={'sku': row['isbn']}).json()
if produtos_existentes and isinstance(produtos_existentes, list) and len(produtos_existentes) > 0:
produto_id = produtos_existentes[0]['id']
resultado_atualizacao = wcapi.put(f"products/{produto_id}", data).json()
if 'id' in resultado_atualizacao:
print(f"Produto {row['name']} atualizado com sucesso! ID: {resultado_atualizacao['id']}")
return
else:
print(f"Erro ao atualizar o produto {row['name']}: {resultado_atualizacao}")
if attempt < max_retries - 1:
print(f"Tentando novamente em {retry_delay} segundos...")
time.sleep(retry_delay)
else:
resultado_criacao = wcapi.post("products", data).json()
if 'id' in resultado_criacao:
print(f"Produto {row['name']} criado com sucesso! ID: {resultado_criacao['id']}")
return
elif resultado_criacao.get('code') == 'woocommerce_rest_product_not_created' and 'already under processing' in resultado_criacao.get('message', ''):
print(f"Produto {row['name']} está sendo processado. Tentando novamente em {retry_delay} segundos...")
time.sleep(retry_delay)
else:
print(f"Erro ao criar o produto {row['name']}: {resultado_criacao}")
return
if row['isbn']:
create_or_update_product(wcapi, row, data)
someone can I help me? please.
- Dominant language
- Python
- Stars
- 216
- Forks
- 108
- Avg merge
- 6h 34m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from woocommerce/wc-api-python
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
woocommerce/wc-api-python#108 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
woocommerce/wc-api-python#106 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
woocommerce/wc-api-python#105 ·
-
Json Formatting Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
woocommerce/wc-api-python#103 ·
-
product-variations Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
woocommerce/wc-api-python#102 · 2 comments ·
All issues in woocommerce/wc-api-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100