0

Running Magento 2.1.10 CE, with multiple stores.

We have all the cache enabled, with Full Page Cache running with Varnish. Having an issue with the minicart values since enabling cache

Steps: 1- Open an individual product page (frontend) 2- clicked add to cart button, 3- Minicart is updated with the count and the content 4- Refresh the page, Minicart shows that the cart is empty 5- Open the cart page (www.site.com/checkout/cart), the count on the mini cart is correct!

When I disable the FullPageCache, it shows the correct count.

I have edited the minicart.phtml file and take out most of the knockout js code. Replaced it with the following

$helper = $this->helper('\Magento\Checkout\Helper\Cart');
$quote = $helper->getQuote();
$quoteitems = $quote->getAllItems();
$totalItemsCount = $helper->getSummaryCount();
echo $totalItemsCount; exit;

On individual product pages, the output is empty, but on cart page the value is correct.

One issue is that we do not cache the cart and checkout pages. With the above code, the value returned is correct, but on other CACHED pages, the value is empty, although. the values on all other cached pages gets updated with the sections ajax call, it does not update on the individual page!

UPDATE

One more thing is with Varnish Full Page Cache enabled,, i am not able to get Customer Session on the cached pages. Need the session to set customer menu in the header! Even after login, the cached pages display the Login form in the header file.

1
  • Seems like your varnish has been configured wrong. Are you sure you have implemented the vcl correctly? Sep 4, 2018 at 12:27

2 Answers 2

0

Firstly, check private data. On chrome browser -> use Inspect -> Application -> Local Storage And check mage-cache-storage key. Is cart updated?

And you can check it on Magento issue https://github.com/magento/magento2/issues/4170

If you cannot find out any solution. you can use my temporary solution (not recommend). Override sections.xml in Checkout module etc/frontend/sections.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="*">
        <section name="cart"/>
    </action>
</config>

Load minicart (cart section data) in all action (effect for performance)

3
  • I have checked the github link you shared, and already have bindSubmit set to "true" .. one more thing is with Varnish Full Page Cache enabled,, i am not able to get Customer Session in the cached pages. Need the session to set customer menu in the header! (updating the original question as well) Sep 4, 2018 at 12:24
  • Try with my solution Sep 4, 2018 at 14:20
  • does not work, sorry, for testing i just edited the section.xml in the vendor after verifying if it was overridden by any extension. compiled and tested, same result Sep 5, 2018 at 10:54
0

Well, I think you should you load/Cache cart components independently, instead of caching the whole page. I reckon that might solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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