update product pudate prices
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
from celery import shared_task
|
||||
from product.models import ProductVariant
|
||||
from order.models import OrderItemModel, OrderModel
|
||||
from product.models import DollorModel, ProductVariant
|
||||
|
||||
@shared_task
|
||||
def update_product_prices():
|
||||
print("\033[92m Calling update product prices from Celery\033[00m")
|
||||
ProductVariant.update_all_prices()
|
||||
print("\033[92m its working\033[00m")
|
||||
def update_prices():
|
||||
# update dollor
|
||||
dollor_object, _ = DollorModel.objects.get_or_create(unique_filed='unique')
|
||||
dollor_object.update_price()
|
||||
dollor_object.save()
|
||||
dollor_price = dollor_object.price
|
||||
|
||||
products = list(ProductVariant.objects.all())
|
||||
for product in products:
|
||||
product.set_or_update_price(dollor_price=dollor_price)
|
||||
ProductVariant.objects.bulk_update(products, ['price'], batch_size=1000)
|
||||
Reference in New Issue
Block a user