Scenario:
I have category landing page, in which another vendor has customized to add "Purchased" text instead of "Add to cart" in case the user has purchased it, hence this will be different for each user.
All iz well till now, until we turned on "The" FPC.
While I understand Holepunching a little better now I had this plan:
My Plan:
- We keep rest code in list.phtml as the same.
- I just cut the logic of the showing of the "Add To Cart" or "Purchased" and put it in another phtml.
- I would add this new block as the child of catalog/product/list block in the catalog.xml with this new phtml.
- Have a container model responsible for the _renderBlock. We say _saveCache false for this block and it would not be cached.
Question / Difficulties
- I am not really aware of the exact implementation for this plan.
- For step 4 what should be the implementation of _renderBlock like ?
- How whould I get the productobject inside this phtml ? as The list.phtml works on the productCollection and we just loop over this and get product object. now, how does one get the project object now in the child block ?
- I need a few pointers on how this can be done best. while I read about a product view page holepunch method I am not exactly sure how to do this for category page.
- If nothing works I just want FPC to not cache the list block at all , but again not sure how to disable caching for only this block ?
Best Answer
So the real question is - is the output of this "Purchased" text coming from a block? Or are you incorporating it in the phtml as logic?
The answer should be that it's coming from a Block. The reasoning is that Magento implements the hole punch via the block output. To do this is very simple:
etc
directory of your moduleetc/cache.xml
Model/Container/Purchased.php