update product pudate prices
This commit is contained in:
@@ -62,7 +62,7 @@ from celery.schedules import crontab
|
|||||||
|
|
||||||
CELERY_BEAT_SCHEDULE = {
|
CELERY_BEAT_SCHEDULE = {
|
||||||
'update-prices-every-minute': {
|
'update-prices-every-minute': {
|
||||||
'task': 'product.tasks.update_product_prices',
|
'task': 'product.tasks.update_prices',
|
||||||
'schedule': crontab(minute='*'),
|
'schedule': crontab(minute='*'),
|
||||||
},
|
},
|
||||||
'update-bank-record-every-minute': {
|
'update-bank-record-every-minute': {
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
from product.models import ProductVariant
|
from order.models import OrderItemModel, OrderModel
|
||||||
|
from product.models import DollorModel, ProductVariant
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def update_product_prices():
|
def update_prices():
|
||||||
print("\033[92m Calling update product prices from Celery\033[00m")
|
# update dollor
|
||||||
ProductVariant.update_all_prices()
|
dollor_object, _ = DollorModel.objects.get_or_create(unique_filed='unique')
|
||||||
print("\033[92m its working\033[00m")
|
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