EE 1.12 で Advance Product Option Extension を実行しています。拡張機能に加えて、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();
}
}