Basket query optimization

Simple optimization for basket to prevent redundant requests to database.