I've created a module that if the customer provides their zipcode then adds a filter to product collections that make it so only plants in their growing zone show up. I'm doing that through extending Mage_Catalog_Model_Layer prepareProductCollection. Now it works fine, does the filtering and the customer can turn it on and off. BUT when Full Page Cache is on it's caching the unfiltered results. (which does make sense since it's not a layered navigation type filter)
I tried even punching a hole for the entire catalog/product_list block but that doesn't work (loads once then the block doesn't load if you refresh the page).
Anyone have any guidance to make the catalog/product_list block caching aware of the the filter status? Alternately, and less ideal but would at least be a solution, how to just disable FPC/hole punch for catalog/product_list ?
I found at least one other person who wasn't able to do it but no followup on it unfortunately. http://magento.stackexchange.com/questions/115918/how-to-hole-punch-catalog-product-list-block
When I tried it initially loads then doesn't show up again on reload, same as that person encountered.
Solved! Go to Solution.
If you take a look at Mage_Catalog_Block_Product_List, you'll notice that it will be hard to render such block without full initialization of Magento app. I'm not saying that it's not possible; but I'll probably spend X hours before figuring out is worth or not.
Instead of that, I can offer you another solution.
When your customer logs in, set cookie as:
setcookie('customer_zip_code', '12345', 0, '/');
Now, you'll have this information available, even when Magento App is not fully initialized.
Rewrite class Enterprise_PageCache_Model_Processor_Category, and modify functions getPageIdInApp and getPageIdWithoutApp by replacing:
$pageId = $processor->getRequestId() . '_' . md5($queryParams);
$zip_code = isset($_COOKIE['customer_zip_code']) ? $_COOKIE['customer_zip_code'] : ''; $pageId = $processor->getRequestId() . '_' . md5($queryParams . $zip_code);
That's all you need.
Background: If you take a look at Enterprise_PageCache_Model_Processor::_createRequestIds(), you'll see how Magento constructs cacheID used for FPC. What we're doing here is adding additional parameter $zip_code which will be used only for serving category pages (with category processor).
By looking at performance side, hole punching catalog/product_list would be better, but also it's too complex to be done easily. This is the only solution that I could offer to you in short period.
If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this issue