From 9adfeaa2373bf6feb03de2ee1b5837a0707643b6 Mon Sep 17 00:00:00 2001 From: lucaslinhares Date: Wed, 17 Jan 2024 11:56:41 -0300 Subject: [PATCH] Get product link --- marketplace/services/vtex/utils/data_processor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/marketplace/services/vtex/utils/data_processor.py b/marketplace/services/vtex/utils/data_processor.py index 462671cc..d661a873 100644 --- a/marketplace/services/vtex/utils/data_processor.py +++ b/marketplace/services/vtex/utils/data_processor.py @@ -32,7 +32,7 @@ class VtexProductDTO: # TODO: Implement This VtexProductDTO class DataProcessor: @staticmethod - def extract_fields(product_details, availability_details) -> FacebookProductDTO: + def extract_fields(domain, product_details, availability_details) -> FacebookProductDTO: price = ( availability_details["price"] if availability_details["price"] is not None @@ -48,6 +48,7 @@ def extract_fields(product_details, availability_details) -> FacebookProductDTO: if product_details.get("Images") else product_details.get("ImageUrl") ) + product_url = f"https://{domain}/{product_details.get('DetailUrl')}" description = ( product_details["ProductDescription"] if product_details["ProductDescription"] != "" @@ -63,7 +64,7 @@ def extract_fields(product_details, availability_details) -> FacebookProductDTO: else "out of stock", condition="new", price=list_price, - link="https://www.google.com.br/", # TODO: Need to set up the product link. + link=product_url, image_link=image_url, brand=product_details.get("BrandName", "N/A"), sale_price=price, @@ -121,7 +122,7 @@ def process_single_sku( continue product_dto = DataProcessor.extract_fields( - product_details, availability_details + domain, product_details, availability_details ) params = {"seller_id": seller_id} if all(rule.apply(product_dto, **params) for rule in rules):