nexcess / magento-turpentine

A Varnish extension for Magento.
GNU General Public License v2.0
519 stars 253 forks source link

ESI policy for blocks with AddTab method #137

Closed donnie-darko closed 11 years ago

donnie-darko commented 11 years ago

Hi, In my custom theme the review block on the products page is in a "tab":

<block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs">
    <action method="setTemplate" >
        <template>catalog/product/view/tabs.phtml</template>
    </action>
    <action method="addTab" translate="title" module="review" >
        <alias>review_tabbed</alias>
        <title>Reviews</title>
        <block>review/product_view_list</block>
        <template>review/product_info_review.phtml</template>
    </action>
</block>

Please give me some advice how to set ESI parameter in this case for this product_view_tabs Thx

aheadley commented 11 years ago

I don't think you'll be able to only do an ESI include for the reviews tab, instead you'd probably need to do the entire tabs block. Additionally, it will probably not be automatically flushed like the reviews page is, the ESI include flushing is currently setup to flush only for private blocks but you'd want the reviews to be public. That said, you could try something like this:

<reference name="product.info.tabs">
    <action method="setEsiOptions">
        <params>
            <access>public</access>
            <registry_keys>
                <currenty_product/>
            </registry_keys>
            <flush_events>
                <review_save_after/>
            </flush_events>
        </params>
    </action>
</reference>
donnie-darko commented 11 years ago

If I set the suggested ESI policy than the tabs block doesn't render at all. Any other idea?

aheadley commented 11 years ago

Unfortunately no, but I'm not real sure why you'd want to ESI include this block anyway, what is your reason for that?

head1328 commented 10 years ago

Sometimes Magento stores the current product under the key "product". As example:

class Mage_Catalog_Block_Product_View_Description extends Mage_Core_Block_Template
{
    protected $_product = null;

    function getProduct()
    {
        if (!$this->_product) {
            $this->_product = Mage::registry('product');
        }
        return $this->_product;
    }
}

just add

<currenty_product/>
<product/>

and it should work.