Skip to content

[Forwardport] magento/magento2#13765 Excess requests 'customer data' on checkout cart page were fixed #14782

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

Merged

Conversation

andrewbess
Copy link
Contributor

Original Pull Request

#14314

Description

The customer/section/load gets called 4 times when loading the cart for the first time. 3 of those times, cart data gets returned. On Magento 2.1, I believe only two calls are made to customer/section/load.

Fixed Issues (if relevant)

  1. "cart" section data gets loaded 3 times on cart page (2.2.2) #13765: "cart" section data gets loaded 3 times on cart page (2.2.2)

Steps to reproduce

  1. Add any product to cart
  2. Go to cart page /checkout/cart with the "Network" panel open in DevTools.

Expected result

  1. The /customer/section/load url should only get called twice. For example, these are the two urls that get called on a Magento 2.1 install:
https://magento22.dev/customer/section/load/?sections=&update_section_id=false&_=1519190370042
https://magento22.dev/customer/section/load/?sections=directory-data&update_section_id=false&_=1519190370043

Actual result

  1. The /customer/section/load url will get called four times:
https://magento22.dev/customer/section/load/?sections=&update_section_id=false&_=1519190370042
https://magento22.dev/customer/section/load/?sections=directory-data&update_section_id=false&_=1519190370043
https://magento22.dev/customer/section/load/?sections=cart&update_section_id=false&_=1519190370045
https://magento22.dev/customer/section/load/?sections=cart&update_section_id=false&_=1519190370046

Note: if you refresh the cart, there will only be two calls made to /customer/section/load.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Andrii Beziazychnyi added 2 commits April 20, 2018 09:19
…ere fixed:

- Excess request for 'directory-data' was fixed;
- Excess requests for 'cart' were fixed.
….2.2):

- Blank line after variable declarations was added;
- Blank line before "if" was added.
@magento-engcom-team
Copy link
Contributor

Hi @andrewbess. Thank you for your contribution.
Changes from your Pull Request will be available with the upcoming 2.3.0 release.

subtotalAmount = parseFloat(cartData().subtotalAmount);

if (quoteSubtotal !== subtotalAmount) {
customerData.reload(['cart'], false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that it will starts to poll remote call after every second in those setups where are defined also taxes as quote.totals().subtotal returns amount without tax but cartData().subtotalAmount is with tax.

Replacing subtotal with subtotal_incl_tax seems to make them equal

- var quoteSubtotal = parseFloat(quote.totals().subtotal),
+ var quoteSubtotal = parseFloat(quote.totals().subtotal_incl_tax),

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Jun 26, 2018

This change was reverted in branch 2.3-develop.
#14314 (comment)
#14314 (comment)

@andrewbess andrewbess deleted the 2.3-develop-PR-port-14314 branch November 13, 2019 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants