We are running a Advance Product Option Extension in EE 1.12. On top of the extension we modified it to use cookies so if customer has selected particular custom options, those are saved in the cookie and next time he visits the product page again the options are populated again from the cookie.
The problem is the Cookie values are Cache in Magento FPC. We tried using hole punching for by passing this but unfortunately it is not working as well.
(1) Is there any other way to counter this issue other than hole punching? (2) As this is a custom module, do we modify the module/etc/cache.xml or pagecache/cache.xml for hole punching.
Regards,
Steve
Below is the part of the code we have for cookie:
<?php
$pres_saved_data = Mage::helper('customoptions')->isCookieExist();
//$cookieModel = Mage::getModel('core/cookie');
//$pres_saved_data = $cookieModel->get('myprescription');
$show_prefilled_data = false;
$pres_data = array();
$other_pres_data = array();
if($pres_saved_data){
$sql = "select * from customer_prescription where id = '".$pres_saved_data."'";
$rowdata = $readConnection->fetchRow($sql);
if($rowdata){
$show_prefilled_data = true;
$optionsdata = unserialize($rowdata['prescription_options']);
$pres_data['options'] = unserialize($optionsdata['options']);
/* store all the option data which is there in cookie*/
$options_data = array(); $options_sku = array();
foreach($pres_data['options'] as $_data){
$label = strtolower(str_replace(" ",'_',$_data['label']));
if($label == 'prescription_type' || $label == 'lens' || $label =='pd' || $label == 'anti_reflective_coating') {
$options_data[] = $_data['value']; $options_sku[] = $_data['sku']; } else{
$other_pres_data[$label] = $_data['value'];
}
}
$sql = sprintf("SELECT v.option_type_id ,t.title,c.option_id,v.sku FROM catalog_product_option as c inner join
`catalog_product_option_type_value` as v
on c.option_id = v.option_id
inner join catalog_product_option_type_title as t on v.option_type_id = t.option_type_id
and v.sku in ('%s') and product_id = %s and t.title in ( '%s') where store_id in( 0,".Mage::app()->getStore()->getId().")",implode("', '",$options_sku),$current_product->getId(),implode("', '",$options_data));
$option_cookie_data = $readConnection->fetchAll($sql);
}
}
?>
<?php endif; ?>
The container we have is :
<?php
class MageWorx_Customoptions_Model_Container_cachetest
extends Enterprise_PageCache_Model_Container_Abstract
{
protected function _getIdentifier()
{
return $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '');
}
protected function _getCacheId()
{
return 'customoptions' . md5($this->_placeholder->getAttribute('cache_id') . $this->_getIdentifier());
}
protected function _renderBlock()
{
$blockClass = $this->_placeholder->getAttribute('block');
$template = $this->_placeholder->getAttribute('template');
$block = new $blockClass;
$block->setTemplate($template);
return $block->toHtml();
}
}