1

I have been pulling my hair out over trying to get a hole punched out for the price block on the product page. I have looked at numerous sources, including some from you good people at stackoverflow, but I have been getting a fatal error, so something is incorrect. Here are some sources that I used:

http://invisiblezero.net/magento-ee-punch-hole-in-full-page-cache/

http://www.kingletas.com/2012/09/how-does-magento-full-page-cache-works.html

Magento full page cache

Trying get dynamic content hole-punched through Magento's Full Page Cache

How to implement magento cache hole punching for shopping cart block

As you can see, I have been all over, and I have read more in addition to this but some of them conflict a litt, and I think that is where I have my issue, now let me post some code for you.

cache.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <placeholders>
         <SpecialPrice>
            <block>catalog/product_price</block>
            <name>product.pricing</name>
            <placeholder>CATALOG_PRODUCT_PRICE</placeholder>
            <container>MyStore_SpecialPrice_Model_Container_Cache</container>
            <cache_lifetime>8640</cache_lifetime>
        </SpecialPrice>
    </placeholders>
</config>

cache.php

<?php
class MyStore_SpecialPrice_Model_Container_Cache extends Enterprise_PageCache_Model_Container_Abstract
{
/**
* Get customer identifier from cookies
*
* @return string
*/
protected function _getIdentifier()
{
return $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '');
}

/**
* Get cache identifier
*
* @return string
*/
protected function _getCacheId()
{
return 'CATALOG_PRODUCT_PRICE' . md5($this->_placeholder->getAttribute('cache_id') . $this->_getIdentifier());
}

/**
* Render block content
*
* @return string
*/
protected function _renderBlock()
{
$blockClass = $this->_placeholder->getAttribute('block');
$template = $this->_placeholder->getAttribute('template');

$block = new $blockClass;
$block->setTemplate($template);
return $block->toHtml();
}
}

congig.xml

<?xml version="1.0"?>
<config>
    <modules>
        <MyStore_SpecialPrice>
            <version>0.1.0</version>
        </MyStore_SpecialPrice>
    </modules>
    <frontend>
        <events>
            <catalog_product_get_final_price>
                <observers>
                    <MyStore_SpecialPrice_Model_Observer>
                        <class>MyStore_SpecialPrice_Model_Observer</class>
                        <method>setSpecialPrice</method>
                    </MyStore_SpecialPrice_Model_Observer>
                </observers>
            </catalog_product_get_final_price>
        </events>
    </frontend>
    <admin>
        <routers>
            <SpecialPrice>
                <use>admin</use>
                <args>
                    <module>MyStore_SpecialPrice</module>
                    <frontName>SpecialPrice</frontName>
                </args>
            </SpecialPrice>
        </routers>
    </admin>
    <global>
        <models>
            <SpecialPrice>
                <class>MyStore_SpecialPrice_Model</class>
            </SpecialPrice>
        </models>
    </global>
</config>

snippet from local.xml

<reference name="right">
            <block type="catalog/product_price" name="product.pricing" template="catalog/product/product-price-block.phtml" before="-" >

Let me know if there is anything that jumps out to you.

Community
  • 1
  • 1
Speed
  • 95
  • 8
  • you need to create a block or knnow the block name thats to be punched.Define a container thats mapped to this block. Then make sure to write a container class.Looks like you have not created a container class. – Oscprofessionals Aug 29 '14 at 18:14
  • 1
    @Satish Thank you for the response! That's curious... None of the example above showed a container class. May I ask where do I create the container class and where do i reference it in the files above? – Speed Sep 01 '14 at 18:20
  • 1
    Here is the error, btw. `Fatal error: Class 'MyStore_SpecialPrice_Model_Container_Cache' not found in /var/www/html/app/code/core/Enterprise/PageCache/Model/Processor/Default.php on line 116` – Speed Sep 01 '14 at 19:45
  • \app\code\core\Enterprise\PageCache\Model\Container here you will find few container classes.Refer those. – Oscprofessionals Sep 02 '14 at 07:06
  • \app\code\core\Enterprise\PageCache\etc also check cache.xml on block mapping. – Oscprofessionals Sep 02 '14 at 07:08

0 Answers0