added log file for woocommerce migrations
This commit is contained in:
@@ -21,6 +21,17 @@ from products.serializers import ProductSerializer
|
||||
from history.models import HistorySync
|
||||
|
||||
|
||||
logging.basicConfig(
|
||||
filename='logs/woocommerce.log',
|
||||
filemode='w',
|
||||
format='%(levelname)s:%(message)s',
|
||||
level=logging.INFO,
|
||||
)
|
||||
|
||||
|
||||
PRODUCT_FIELDS = [f.name for f in Product._meta.get_fields()]
|
||||
|
||||
|
||||
def get_wcapi_instance(url, key, secret, version="wc/v3"):
|
||||
wcapi = API(
|
||||
url=url,
|
||||
@@ -32,9 +43,6 @@ def get_wcapi_instance(url, key, secret, version="wc/v3"):
|
||||
return wcapi
|
||||
|
||||
|
||||
PRODUCT_FIELDS = [f.name for f in Product._meta.get_fields()]
|
||||
|
||||
|
||||
def create_imported_product(info, company, history, user):
|
||||
# extract m2m field data
|
||||
tags = [t.get('name') for t in info.pop('tags')]
|
||||
@@ -84,7 +92,6 @@ def create_imported_product(info, company, history, user):
|
||||
return []
|
||||
|
||||
|
||||
|
||||
def migrate_shop_products(url, key, secret, user=None, version="wc/v3"):
|
||||
"""Tries to connect to WooCommerce site @ url with given credentials
|
||||
|
||||
@@ -123,7 +130,8 @@ def migrate_shop_products(url, key, secret, user=None, version="wc/v3"):
|
||||
return None
|
||||
except requests.exceptions.ReadTimeout as e:
|
||||
logging.error(f"Timeout reading backend: {str(e)}")
|
||||
return None
|
||||
# skip and try next
|
||||
continue
|
||||
# exit loop if no more products
|
||||
if not products:
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user