我们正在 EE 1.12 中运行高级产品选项扩展。在扩展之上,我们将其修改为使用 cookie,因此如果客户选择了特定的自定义选项,这些选项将保存在 cookie 中,并且下次他再次访问产品页面时,这些选项会再次从 cookie 中填充。
问题是 Cookie 值是 Magento FPC 中的缓存。我们尝试通过这个来使用打孔,但不幸的是它不能正常工作。
(1) 除了打孔还有其他方法可以解决这个问题吗?(2) 由于这是一个自定义模块,我们是否修改模块/etc/cache.xml 或pagecache/cache.xml 进行打孔。
问候,
史蒂夫
以下是我们为 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; ?>
我们拥有的容器是:
<?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();
}
}