Updated fetch_price script to store store name
This commit is contained in:
parent
fa9934bb4d
commit
972bb62197
|
@ -13,6 +13,14 @@ from amiibofindr.apps.shop.crawlers import Crawler
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
def update_product(self, product, region):
|
||||||
|
amiibo_shop = AmiiboShop.objects.get(
|
||||||
|
item_id=product['shop_product_id'],
|
||||||
|
shop__flag_code=region[0]
|
||||||
|
)
|
||||||
|
amiibo_shop.shop_name = product.title
|
||||||
|
amiibo_shop.update_price(product['price'], product['currency'])
|
||||||
|
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
regions = Shop.objects.all()\
|
regions = Shop.objects.all()\
|
||||||
.order_by('flag_code')\
|
.order_by('flag_code')\
|
||||||
|
@ -27,14 +35,6 @@ class Command(BaseCommand):
|
||||||
products = amazon.fetch_batch(item_codes)
|
products = amazon.fetch_batch(item_codes)
|
||||||
try:
|
try:
|
||||||
for product in products:
|
for product in products:
|
||||||
amiibo_shop = AmiiboShop.objects.get(
|
self.update_product(product, region)
|
||||||
item_id=product['shop_product_id'],
|
|
||||||
shop__flag_code=region[0]
|
|
||||||
)
|
|
||||||
amiibo_shop.update_price(product['price'], product['currency'])
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
amiibo_shop = AmiiboShop.objects.get(
|
self.update_product(product, region)
|
||||||
item_id=product['shop_product_id'],
|
|
||||||
shop__flag_code=region[0]
|
|
||||||
)
|
|
||||||
amiibo_shop.update_price(product['price'], product['currency'])
|
|
||||||
|
|
Loading…
Reference in New Issue