GordonLesti / Lesti_Fpc

Simple Magento Fullpagecache
https://gordonlesti.com/lesti-fpc-documentationversion-1-4-5/
Other
358 stars 159 forks source link

Magento Minicart block isn't updated after user deletes/updates cart #287

Closed Muthukumarcse10 closed 7 years ago

Muthukumarcse10 commented 7 years ago

Hello Team,

We are having an issue with mini cart on right top of our website which does not stay dynamic. When a product is added, Minicart is been updated, but when I go back to the homepage, the homepage does not reflect the items on the Minicart, this is happening with all the pages, Minicart status of that particular page does not carry forward to next page, be it homepage or any other page. Please help how to solve this.

1) Add some product to cart (Product added to Minicart) 2) Go to home page so it gets cached (Minicart became 0) 3) Go to other pages (Minicart values are shown) 4) Open Minicart at the top, delete the product 5) Go to home page again

We are using Ves_fashion theme in our Magento store (http://dev.islamicshop.in/), please let us know your best solution.

Thanks in advance!

GordonLesti commented 7 years ago

Hello @Muthukumarcse10 I guess you may need to configure your minicart as dynamic or lazy block.

Muthukumarcse10 commented 7 years ago

Thanks for your quick reply @GordonLesti ! I did added minicart in dynamic blocks & my dynamic blocks as follows,

Dynamic Blocks: global_messages, messages, global_notices, global_cookie_notice, right.reports.product.viewed, cart_sidebar, sidebar.minicart

Referesh Actions: checkout_cart, checkout_cart_add, checkout_cart_delete, checkout_cart_updatePost, checkout_cart_ajaxDelete, checkout_cart_ajaxUpdate, checkout_cart_updateItemOptions, catalog_product_compare_add, catalog_product_compare_clear, catalog_product_compare_remove, wishlist_index_add, wishlist_index_remove, wishlist_index_update, wishlist_index_allcart, wishlist_index_configure, checkout_onepage, checkout_onepage_success, customer_account_login

lazy Blocks: top.links, cart_sidebar, catalog.compare.sidebar, right.reports.product.compared, wishlist_sidebar, welcome, minicart_head, sidebar.minicart

GordonLesti commented 7 years ago

And you are sure that the name of the block is sidebar.minicart? You should avoid that a block is dynamic and lazy, a block can only be dynamic or lazy.

Muthukumarcse10 commented 7 years ago

yes. The block name is sidebar.minicart ?

I did try putting sidebar.minicart in Dynamic or Lazy block alone, but no luck.

Minicart is working fine when excluding cms_index_index & cms_page_view from the cacheable actions.

GordonLesti commented 7 years ago

Can you post some content of the responsible layout xml file just to make sure? I guess you will have also a problem on catalog_product_view after refreshing the page.

Muthukumarcse10 commented 7 years ago

Now, I put sidebar.minicart to dynamic blocks, still the same issue persists.

You mean layout xml file for Minicart block ?

Muthukumarcse10 commented 7 years ago

Catalog_product_view layout xml section as follows,

<catalog_product_view translate="label">
    <label>Catalog Product View (Any)</label>
    <!-- Mage_Catalog -->
    <reference name="root">
        <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
    </reference>
    <reference name="head">
        <action method="addJs"><script>varien/product.js</script></action>
        <action method="addJs"><script>varien/configurable.js</script></action>

        <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
        <action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
        <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
    </reference>
    <reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
            <!--
            <action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/summary.phtml</template></action>
            <action method="addReviewSummaryTemplate"><type>short</type><template>review/helper/summary_short.phtml</template></action>
            <action method="addReviewSummaryTemplate"><type>...</type><template>...</template></action>
            -->
            <block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml">
                <block type="core/text_list" name="product.info.media.after" as="after" />
            </block>
            <block type="core/text_list" name="alert.urls" as="alert_urls" translate="label">
                <label>Alert Urls</label>
            </block>

            <action method="setTierPriceTemplate"><template>catalog/product/view/tierprices.phtml</template></action>

            <block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml">
                <action method="setColumnCount"><columns>14</columns></action>
                <action method="setItemLimit"><type>upsell</type><limit>14</limit></action>
            </block>

            <block type="catalog/product_view_additional" name="product.info.additional" as="product_additional_data" />
            <block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
                <action method="addToParentGroup"><group>detailed_info</group></action>
            </block>
            <block type="catalog/product_view_attributes" name="product.attributes" as="additional" template="catalog/product/view/attributes.phtml">
                <action method="addToParentGroup"><group>detailed_info</group></action>
            </block>
            <block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/>
            <block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/>

            <block type="core/text_list" name="product.info.extrahint" as="extrahint" translate="label">
                <label>Product View Extra Hint</label>
            </block>

            <block type="catalog/product_view" name="product.info.options.wrapper" as="product_options_wrapper" template="catalog/product/view/options/wrapper.phtml" translate="label">
                <label>Info Column Options Wrapper</label>
                <block type="core/template" name="options_js" template="catalog/product/view/options/js.phtml"/>
                <block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml">
                    <action method="addOptionRenderer"><type>text</type><block>catalog/product_view_options_type_text</block><template>catalog/product/view/options/type/text.phtml</template></action>
                    <action method="addOptionRenderer"><type>file</type><block>catalog/product_view_options_type_file</block><template>catalog/product/view/options/type/file.phtml</template></action>
                    <action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>catalog/product/view/options/type/select.phtml</template></action>
                    <action method="addOptionRenderer"><type>date</type><block>catalog/product_view_options_type_date</block><template>catalog/product/view/options/type/date.phtml</template></action>
            </block>
                    <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
                </block>
            <block type="catalog/product_view" name="product.info.options.wrapper.bottom" as="product_options_wrapper_bottom" template="catalog/product/view/options/wrapper/bottom.phtml" translate="label">
                <label>Bottom Block Options Wrapper</label>
                <action method="insert"><block>product.tierprices</block></action>
                <block type="catalog/product_view" name="product.clone_prices" as="prices" template="catalog/product/view/price_clone.phtml"/>
                <action method="append"><block>product.info.addtocart</block></action>
                <action method="append"><block>product.info.addto</block></action>
            </block>

            <block type="core/template_facade" name="product.info.container1" as="container1">
                <action method="setDataByKey"><key>alias_in_layout</key><value>container1</value></action>
                <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action>
                <action method="append"><block>product.info.options.wrapper</block></action>
                <action method="append"><block>product.info.options.wrapper.bottom</block></action>
            </block>
            <block type="core/template_facade" name="product.info.container2" as="container2">
                <action method="setDataByKey"><key>alias_in_layout</key><value>container2</value></action>
                <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action>
                <action method="append"><block>product.info.options.wrapper</block></action>
                <action method="append"><block>product.info.options.wrapper.bottom</block></action>
            </block>

            <block type="catalog/product_view_tabs" name="product.info.review" as="review_tab" template="catalog/product/view/reviewtab.phtml">
                    <block type="page/html_pager" name="product_review_list.toolbar" />
                    <block type="core/template" name="product_review_list.count" template="review/product/view/count.phtml" />
                    <block type="review/product_view_list" name="product.info.product_additional_data" as="info_tabs" template="review/product/view/list.phtml">
                    <block type="review/form" name="product.review.form" as="review_form"/>
                    </block>
            </block>

            <action method="unsetCallChild"><child>container1</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action>
            <action method="unsetCallChild"><child>container2</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action>
        </block>
    </reference>
    <reference name="left">
        <block type="catalog/product_list_related" name="catalog.product.related" after="treemenu" template="catalog/product/list/related.phtml"/>
    </reference>
</catalog_product_view>
GordonLesti commented 7 years ago

I mean the layout xml file that defines the block. For example in the Magento RWD Theme checkout.xml. Please make sure that your Theme is maybe not using an other name for that block.

Muthukumarcse10 commented 7 years ago

There is no explicit block mentioned for page/html/minicart.phtml template in any of the layout xml file.

Checkout.xml layout of the theme contains cart_sidebar block as follows,

    <reference name="right">
        <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
            <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
            <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
            <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
            <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
                <label>Shopping Cart Sidebar Extra Actions</label>
            </block>
        </block>
    </reference>
Muthukumarcse10 commented 7 years ago

Minicart block is defined in the Helper class of the theme extension as follows,

    public function getMinicartBlock($options = array()) {
        $output = Mage::app()->getLayout()
                        ->createBlock("checkout/cart_sidebar", "sidebar.minicart")
                        //->setTemplate('checkout/cart/sidebar.phtml') //Lesti FPC fix for minicart
                        ->setCacheLifetime(null)
                        ->addData(array("cache_lifetime"=>null))
                        ->setTemplate("checkout/cart/sidebar.phtml")
                        ->toHtml();
        return $output;
    }

    public function getMinicartHtml() {
        $output = Mage::app()->getLayout()
                        ->createBlock("checkout/cart_sidebar", "venus.minicart")
                        ->setCacheLifetime(null)
                        ->addData(array("cache_lifetime"=>null))
                        ->setTemplate('page/html/minicart.phtml')
                        ->toHtml();
        return $output;
    }
GordonLesti commented 7 years ago
Muthukumarcse10 commented 7 years ago
GordonLesti commented 7 years ago

My guess, the block name is right if the minicart disappears after adding to dynamic blocks, but something else is maybe not working with your theme. I am sorry, but I can not help you in this case.

Muthukumarcse10 commented 7 years ago

Thanks for your great time & support @GordonLesti .

1) Is cms_index_index, cms_page_view mandate for cacheable actions ? 2) Can we exclude cms_index_index, cms_page_view ? 3) Is there any possibilites to exclude a particular block (i.e Minicart) from caching ?

GordonLesti commented 7 years ago
  1. cms_index_index and cms_page_view are default cacheable actions.
  2. You can remove cms_index_index and cms_page_view from cacheable actions, but note that this will prevent FPC from working on those pages.
  3. Yes, there is a way. You just need to add the name of a block in layout to the dynamic block config of FPC. This post may help you to find the block name. But this block has to be defined in a layout xml file and should have no child blocks.