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"
 | 
			
		||||
 | 
			
		||||
    async def get_products(self, data: dict) -> dict:
 | 
			
		||||
        method = '/v2/product/list'
 | 
			
		||||
        method = '/v3/product/list'
 | 
			
		||||
        response = await  self._method('POST', method, json=data)
 | 
			
		||||
        return response
 | 
			
		||||
 | 
			
		||||
@@ -36,7 +36,9 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
 | 
			
		||||
            data = {
 | 
			
		||||
                'limit': limit,
 | 
			
		||||
                'last_id': last_id,
 | 
			
		||||
 | 
			
		||||
                'filter':{
 | 
			
		||||
                    'visibility': 'ALL',
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            response = await self.get_products(data)
 | 
			
		||||
            if not response:
 | 
			
		||||
@@ -54,7 +56,7 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
 | 
			
		||||
                break
 | 
			
		||||
 | 
			
		||||
    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)
 | 
			
		||||
        return response
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ class OzonProductSynchronizer(BaseProductSynchronizer):
 | 
			
		||||
        if primary_image:
 | 
			
		||||
            image = ProductImage(
 | 
			
		||||
                product=product,
 | 
			
		||||
                image_url=primary_image
 | 
			
		||||
                image_url=primary_image[0]
 | 
			
		||||
            )
 | 
			
		||||
            return [image]
 | 
			
		||||
        product_images = []
 | 
			
		||||
@@ -84,7 +84,7 @@ class OzonProductSynchronizer(BaseProductSynchronizer):
 | 
			
		||||
            products_info = await self.api.get_products_info(data)
 | 
			
		||||
            if not products_info:
 | 
			
		||||
                continue
 | 
			
		||||
            result = products_info.get('result')
 | 
			
		||||
            result = products_info
 | 
			
		||||
            if not result:
 | 
			
		||||
                continue
 | 
			
		||||
            items = result.get('items')
 | 
			
		||||
@@ -131,7 +131,7 @@ class OzonProductSynchronizer(BaseProductSynchronizer):
 | 
			
		||||
            products_info = await self.api.get_products_info(data)
 | 
			
		||||
            if not products_info:
 | 
			
		||||
                continue
 | 
			
		||||
            result = products_info.get('result')
 | 
			
		||||
            result = products_info
 | 
			
		||||
            if not result:
 | 
			
		||||
                continue
 | 
			
		||||
            items = result.get('items')
 | 
			
		||||
@@ -169,6 +169,9 @@ class OzonProductSynchronizer(BaseProductSynchronizer):
 | 
			
		||||
    def _update_images(self, product, product_info):
 | 
			
		||||
        existing_images = {image.image_url for image in product.images}
 | 
			
		||||
        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:
 | 
			
		||||
            image = ProductImage(
 | 
			
		||||
                product=product,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user