diff --git a/engine/core/vendors/__init__.py b/engine/core/vendors/__init__.py index 85452f5a..8658e0f2 100644 --- a/engine/core/vendors/__init__.py +++ b/engine/core/vendors/__init__.py @@ -155,8 +155,12 @@ class AbstractVendor: filename = f"response_{timestamp}.json" content = ContentFile(json_bytes) + self.log(LogLevel.DEBUG, f"Saving vendor's response to {filename}") + vendor_instance.last_processing_response.save(filename, content, save=True) + self.log(LogLevel.DEBUG, f"Saved vendor's response to {filename} successfuly!") + return raise VendorDebuggingError("Could not save response") @@ -451,17 +455,23 @@ class AbstractVendor: return attr - def process_attribute(self, key: str, value: Any, product: Product, attr_group: AttributeGroup) -> None: + def process_attribute( + self, key: str, value: Any, product: Product, attr_group: AttributeGroup + ) -> AttributeValue | None: + self.log( + LogLevel.DEBUG, f"Trying to save attribute {key} with value {value} to {attr_group.name} of {product.pk}" + ) + if not value: self.log(LogLevel.WARNING, f"No value for attribute {key!r} at {product.name!r}...") - return + return None if not attr_group: self.log(LogLevel.WARNING, f"No group for attribute {key!r} at {product.name!r}...") - return + return None if key in self.blocked_attributes: - return + return None value, attr_value_type = self.auto_convert_value(value) @@ -498,18 +508,25 @@ class AbstractVendor: raise except IntegrityError: self.log(LogLevel.WARNING, f"IntegrityError while processing attribute {key!r}...") - return + return None if not is_created: - return + return None - AttributeValue.objects.get_or_create( + av, _ = AttributeValue.objects.get_or_create( attribute=attribute, value=value, product=product, defaults={"is_active": True}, ) + self.log( + LogLevel.DEBUG, + f"Succesfully saved attribute {key} with value {value} to {attr_group.name} of {product.pk} into {av.uuid}", + ) + + return av + def update_stock(self) -> None: pass