16

With Magento 2.0.4 cache, more specifically page cache enabled, everything works.

If I disable it, clear cookies, and login as customer than products in minicart are not there.

Welcome message does not really work right. I have to add a product to cart from a product page in order to see the minicart. Than if I go to checkout, country is not displayed in address summary (shipping address already added in my account).

I've done debugging and it looks like the problem is pointing to: module-customer/view/frontend/web/js/customer-data.js. The cookie private_content_version is set in module-page-cache/view/frontend/web/js/page-cache.js and used in customer-data.js. See customerData::reload function.

With page cache disabled, the data is not loaded from the server as the function dataProvider::getFromServer() does.

When page cache is disabled the cookie private_content_version is not there (page-cache.js is not executed off course). But the cookie section_data_ids has only '*' and 'messages' => empty (false or null).

When page cache is enabled there is private_content_version and section_data_ids has what keys with values:

*:      null
cart:       123
compare-products:       123
customer:       123
directory-data:     123
last-ordered-items:     123
multiplewishlist:       123
review:     123
wishlist:       123

After I login with page cache enabled, on customer dashboard there are 2 additional ajax requests that load data:

http://test.localhost/customer/section/load/?sections=&update_section_id=false&_=123 http://test.localhost/customer/section/load/?sections=directory-data&update_section_id=false&_=123

These contain json objects with customer specific data and directory data like all countries and regions. With these calls, on checkout the address summary displays the country name. See: module-customer/view/frontend/web/js/sections-config.js and module-checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js, function getCountryName.

Is this a Magento 2 bug or it's something that I messed up ? Thanks

  • Have you been able to fix this or find what exactly is causing this? I've got very similar issue, Magento ver. 2.0.1. If I flush the cache (deleting all cache folders) I get similar error message in the browser console: GET http://example.com/customer/section/load/?sections=&update_section_id=false&_=1462374643065 500 (Internal Server Error) – maginfortis May 11 '16 at 10:22
  • 1
    Haven't found a solution yet. In your case it may be a simpler case. See what the error is and try to fix it. Enable errors in Magento 2 and work around that specific error. I don't get errors, it's just that it doesn't load the data. I haven't seen errors in my case. – obscure May 14 '16 at 9:02
  • I have faced same error and i will say its a magento2 bug as with FPC enabled it will work but once you disable it will not. To fix it temporary you need to refresh minicart programmatically on each page. – Salma Saiyad Dec 22 '16 at 4:08
0

This does appear to be an outstanding issue, though perhaps it is resolved in newer versions of M2. See Magento GitHub issues:

As far as what you can try...

If this is cookie-related, you may be able to rule out some possibilities by visiting your site in a private browsing/incognito browser. Go through your workflow (not logged in, add product to cart, customer log in, look at /checkout/cart and minicart dropdown).

Additionally, it may be helpful to review the M2 dev docs for best practices regarding configuration of the caches in development versus configuration in production. In my experience, in development, it is OK to have all caches enabled in development, and simply flush when required (read docs for descriptions of each cache). Note, as a mostly front-end dev, I personally prefer to develop with FPC, Blocks output, and layout caches disabled - this allows frontend changes to be seen more easily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.