You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our implementation of oscar ecommerce we have found that, in some cases under heavy load, many baskets are not able to access its vouchers and apply offers.
Steps to Reproduce
We have extended the BasketMiddleware and overridden the method apply_offers_to_basket to add logic to this process.
So our method looks like this:
defapply_offers_to_basket(self, request, basket):
# Clean up not applicable vouchers before using applicatorifbasketandbasket.id:
forvoucherinbasket.vouchers.all():
can_be_applied, __=voucher.can_be_applied(user=basket.owner)
ifnotcan_be_applied:
basket.vouchers.remove(voucher)
We are facing many exceptions in the basket.voucher.all() part, where Django loses the _prefetched_objects_cache and it cannot access its Vouchers.
Possible solution
We believe that we could fix this issue by prefetching the vouchers in the get_basket method in BasketMiddleware.
Issue Summary
In our implementation of oscar ecommerce we have found that, in some cases under heavy load, many baskets are not able to access its vouchers and apply offers.
Steps to Reproduce
We have extended the
BasketMiddleware
and overridden the methodapply_offers_to_basket
to add logic to this process.So our method looks like this:
We are facing many exceptions in the
basket.voucher.all()
part, where Django loses the_prefetched_objects_cache
and it cannot access its Vouchers.Possible solution
We believe that we could fix this issue by prefetching the vouchers in the
get_basket
method inBasketMiddleware
.django-oscar/src/oscar/apps/basket/middleware.py
Lines 132 to 135 in 3dee0ae
So the fix could look like
Technical details
The text was updated successfully, but these errors were encountered: