Skip to content

Commit

Permalink
Prepare system for possible future name of product in payload
Browse files Browse the repository at this point in the history
  • Loading branch information
matacoder committed Jul 27, 2023
1 parent a9cb412 commit e722fd6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion templates/includes/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</figure>
</div>
<div class="card-content">
<p class="title is-5"><a href="https://seller.wb.ru/new-goods/product-card/card?vendorCode={{ item.supplier_article }}" target="_blank">{{ item.brand }} {{ item.category }} {{ item.subject }} {{ item.name }}<br>
<p class="title is-5"><a href="https://seller.wb.ru/new-goods/product-card/card?vendorCode={{ item.supplier_article }}" target="_blank">{{ item.brand }} {{ item.category }} {{ item.subject }} {{ item.name }} {{ item.object }}<br>
✏️редактировать</a></p>
<p class="block"> {% for size in item.sizes.values %}<span class="button is-light">
<span class="tag is-success">{{ size.tech_size }}</span>&nbsp;
Expand Down
1 change: 1 addition & 0 deletions wb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Product:
category: str = ""
brand: str = ""
image: str = ""
object: str = ""

days_on_site: str = ""
has_been_updated: dict = field(default_factory=dict)
Expand Down
10 changes: 6 additions & 4 deletions wb/services/rest_client/standard_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_content(self):
}
}
}
images = dict()
content = dict()
total = 1000 # Any number above 1000 will do
limit = 1000
while total >= limit:
Expand All @@ -151,10 +151,12 @@ def get_content(self):
cards = data["cards"]

for card in cards:
images[card["nmID"]] = card["mediaFiles"][0]
content[card["nmID"]] = {
"image": card["mediaFiles"][0],
"object": card["object"]
}
else:
logger.info(response.text)
break
logger.info("Exit loop")
return images

return content
3 changes: 2 additions & 1 deletion wb/services/warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,6 @@ def attach_images(standard_token, products: dict):
images = client.get_content()
for wb_id, product in products.items():
if wb_id in images:
product.image = images[wb_id]
product.image = images[wb_id]["image"]
product.object = images[wb_id]["object"]
return products

0 comments on commit e722fd6

Please sign in to comment.