Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue duplicate query when use cart() helper #22

Open
vanthao03596 opened this issue May 14, 2020 · 1 comment
Open

Performance issue duplicate query when use cart() helper #22

vanthao03596 opened this issue May 14, 2020 · 1 comment

Comments

@vanthao03596
Copy link

Describe the bug
cart() helper hit database query every time.
example:
protected function getCartDetails() { return [ 'items' => cart()->items($displayCurrency = true), 'totals' => cart()->totals(), ]; }
This function will hit database multiple times.
To Reproduce
Steps to reproduce the behavior:

  1. Clone demo
  2. Install debugbar
  3. We will see duplicate query

Expected behavior
No duplicate query during request

Screenshots
1

Additional context
Suguest fix: Change bind to singleton in CartManagerServiceProvider

@gauravmak
Copy link
Member

Thanks for reporting.

As per the current code status, the downside is that the items are not updated in the Cart object array resulting in data inconsistencies. To solve the DB queries issue, we will need to update some parts of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants