1

I have a static block i reuse on different pages and when I call this block I'm 'feeding' it 4 product SKU's, different SKU's for different pages, its like a specials/promotion block. However, when I browse between the pages the products remain the same. If I disable BLOCK_HTML cache it all works well but I dont want to keep it disabled. I'm using 1.9.2.4 which I thought had the block cache issue fixed?

In my CMS pages, I'm using this to call the block...

{{block type="venedor/product_list_featured" is_wide="1" sku1="abc123" sku2="abc456" sku3="abc789" sku4="abc321" url="/products/ropes-twines-chains.html" template="catalog/product/brandrepeater.phtml"}}

From a CMS page, how can I ensure this block is excluded from cache?

  • Have you created your own block class in a module? There are a couple of ways of doing this, but i want to understand what your calling a little bit better. – circlesix Feb 22 '17 at 14:15
  • hi i just created a .phtml file that i call with the block statement above. This .phtml files takes the SKU and URL date passed by the above statement to render a simple 4 product grid of said products. I have just now, gone ahead and created separate template files just to get it working as its a live site. – Mike Feb 22 '17 at 14:34
0

Please replace your code with this:

{{block type="venedor/product_list_featured" is_wide="1" sku1="abc123" sku2="abc456" sku3="abc789" sku4="abc321" url="/products/ropes-twines-chains.html" template="catalog/product/brandrepeater.phtml" cache_lifetime=0  cache_tags="CACHE_TAG_MY_BLOCK" cache_key="my-block"}}

If above solution not works.Then create separate static block and template file for each page.

  • thanks guys but neither of these are working for me. I have 20+ CMS pages I use this block in so dont want to have to create a new template for each CMS page! If I add cache_tags or cache_key it just renders blank page with no error output! – Mike Feb 22 '17 at 13:33
0

just set cache_lifetime=0

{{block type="venedor/product_list_featured" is_wide="1" sku1="abc123" sku2="abc456" sku3="abc789" sku4="abc321" url="/products/ropes-twines-chains.html" template="catalog/product/brandrepeater.phtml" cache_lifetime=0 }}
0

One way to do this is to call the phtml in the design section of the CMS Page (cms-> pages-> design-> Layout Update XML). When you call in a phtml this way, you have access to some other methods that can help control the cache. The placement of the phtml will depend on the load order of the page, and without seeing the design you have, i won't be able to say where you need it, but using the before="-" and after="-" should get you close.

<reference name="content" before="-">
   <block type="core/template" name="your_custom_name" template="catalog/product/brandrepeater.phtml">
      <action method="setCacheLifetime"><s>0</s></action>
   </block>
</reference>

From inside the phtml, you can then call the cms block they way you currently are and they whole page will not be cached.

There is one catch, outlined here:

http://fbrnc.net/blog/2015/06/cache-and-layout-xml-tricks

You might run into the value for setCacheLifetime not reading at null or 0 but as the string "0". Which in magento reads as true. If that is the case, there is a little more work that you will need to do. There is some more cache idea's and info here:

Do not cache footer

How can I disable cache for particular section or block

Also, since you are on the live site, you should be able to get away with installing Fabrizio's template hints extension to check if a block in the page is in fact being cached.

https://github.com/AOEpeople/Aoe_TemplateHints

Not the answer you're looking for? Browse other questions tagged or ask your own question.