improvements to WC migration script
This commit is contained in:
@@ -53,6 +53,7 @@ def create_imported_product(info, company, history, user):
|
||||
'creator': user.id if user is not None else None,
|
||||
'history': history.id,
|
||||
'url': info['permalink'],
|
||||
'stock': info['stock_quantity'],
|
||||
}
|
||||
# parse the product info
|
||||
for key in info:
|
||||
@@ -144,6 +145,13 @@ def migrate_shop_products(url, key, secret, user=None, version="wc/v3"):
|
||||
|
||||
counter = 0
|
||||
for product in products:
|
||||
# check if exists
|
||||
if product['sku'] and Product.objects.filter(sku=product['sku']).exists():
|
||||
# product already registered
|
||||
logging.info(f"Product with sku [{product['sku']}] already registered")
|
||||
print(f"Product with sku [{product['sku']}] already registered")
|
||||
# TODO: UPDATE instance??
|
||||
continue
|
||||
new = create_imported_product(product, company, history, user)
|
||||
if new is not None:
|
||||
new_products.append(new)
|
||||
|
||||
Reference in New Issue
Block a user