feat: new handies for ozon
This commit is contained in:
8
external/marketplace/ozon/core.py
vendored
8
external/marketplace/ozon/core.py
vendored
@@ -25,7 +25,7 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
|
|||||||
return "https://api-seller.ozon.ru"
|
return "https://api-seller.ozon.ru"
|
||||||
|
|
||||||
async def get_products(self, data: dict) -> dict:
|
async def get_products(self, data: dict) -> dict:
|
||||||
method = '/v2/product/list'
|
method = '/v3/product/list'
|
||||||
response = await self._method('POST', method, json=data)
|
response = await self._method('POST', method, json=data)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@@ -36,7 +36,9 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
|
|||||||
data = {
|
data = {
|
||||||
'limit': limit,
|
'limit': limit,
|
||||||
'last_id': last_id,
|
'last_id': last_id,
|
||||||
|
'filter':{
|
||||||
|
'visibility': 'ALL',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
response = await self.get_products(data)
|
response = await self.get_products(data)
|
||||||
if not response:
|
if not response:
|
||||||
@@ -54,7 +56,7 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
|
|||||||
break
|
break
|
||||||
|
|
||||||
async def get_products_info(self, data: dict) -> dict:
|
async def get_products_info(self, data: dict) -> dict:
|
||||||
method = '/v2/product/info/list'
|
method = '/v3/product/info/list'
|
||||||
response = await self._method('POST', method, json=data)
|
response = await self._method('POST', method, json=data)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class OzonProductSynchronizer(BaseProductSynchronizer):
|
|||||||
if primary_image:
|
if primary_image:
|
||||||
image = ProductImage(
|
image = ProductImage(
|
||||||
product=product,
|
product=product,
|
||||||
image_url=primary_image
|
image_url=primary_image[0]
|
||||||
)
|
)
|
||||||
return [image]
|
return [image]
|
||||||
product_images = []
|
product_images = []
|
||||||
@@ -84,7 +84,7 @@ class OzonProductSynchronizer(BaseProductSynchronizer):
|
|||||||
products_info = await self.api.get_products_info(data)
|
products_info = await self.api.get_products_info(data)
|
||||||
if not products_info:
|
if not products_info:
|
||||||
continue
|
continue
|
||||||
result = products_info.get('result')
|
result = products_info
|
||||||
if not result:
|
if not result:
|
||||||
continue
|
continue
|
||||||
items = result.get('items')
|
items = result.get('items')
|
||||||
@@ -131,7 +131,7 @@ class OzonProductSynchronizer(BaseProductSynchronizer):
|
|||||||
products_info = await self.api.get_products_info(data)
|
products_info = await self.api.get_products_info(data)
|
||||||
if not products_info:
|
if not products_info:
|
||||||
continue
|
continue
|
||||||
result = products_info.get('result')
|
result = products_info
|
||||||
if not result:
|
if not result:
|
||||||
continue
|
continue
|
||||||
items = result.get('items')
|
items = result.get('items')
|
||||||
@@ -169,6 +169,9 @@ class OzonProductSynchronizer(BaseProductSynchronizer):
|
|||||||
def _update_images(self, product, product_info):
|
def _update_images(self, product, product_info):
|
||||||
existing_images = {image.image_url for image in product.images}
|
existing_images = {image.image_url for image in product.images}
|
||||||
primary_image = product_info.get('primary_image')
|
primary_image = product_info.get('primary_image')
|
||||||
|
if isinstance(primary_image,list) and primary_image:
|
||||||
|
primary_image = primary_image[0]
|
||||||
|
|
||||||
if primary_image and primary_image not in existing_images:
|
if primary_image and primary_image not in existing_images:
|
||||||
image = ProductImage(
|
image = ProductImage(
|
||||||
product=product,
|
product=product,
|
||||||
|
|||||||
Reference in New Issue
Block a user