I'm strugling with disabling the cache for an individual block in Magento 1.9. I've enabled the "HTML Blocks" in cache management and the site is much faster although I have a static block on the product page that stays the same when it should refresh depending on the supplier of the product.
The Static block is called block_product_secondary_bottom and in that block is the following:
<p class="no-margin ">{{block type="core/template" name="supplier.delivery" template="myphp/delivery.phtml"}}</p>
myphp/delivery.phtml contains the following code - basically it looks up info from a table:
<?php
$product_id = Mage::registry('current_product')->getId();
$attributeValue = Mage::getModel('catalog/product')
->load($product_id)
->getAttributeText('advertiser_name');
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$query = "Select * from `smashingmagazine_branddirectory_brand` Where `name`='".$attributeValue."'";
$rows = $connection->fetchAll($query);
$output = 0;
foreach ($rows as $values) {
$name = $attributeValue;
$about = $values['about_supplier'];
$discounts = $values['description'];
$image = $values['url_key'];
}
if (!empty($name)) {
$output = '<h6 class="block-title heading" style="text-align: center; font-weight:bold;">About '.$name.'</h6>
<div class="block-content">';
};
if (!empty($image)) {
$output.= '<p class="no-margin "style="text-align: center;"><img src='.$image.'></p>';
};
if (!empty($about)) {
$output.= '<p class="no-margin ">'.$about.'</p>';
};
if (!empty($discounts)) {
$output.= '<div class="feature feature-icon-hover indent first" style="padding-top:15px;">
<span class="ib ic ic-lg ic-plane"></span>
<p class="no-margin ">'.$discounts.'</p></div>';
};
$output.= "</div>";
echo $output;
I've tried adding the following code into my local.xml, clearing Cache and refreshing - but this doesn't work:
<block name="supplier.delivery" template="myphp/delivery.phtml" type="core/template">
<action method="unsetData">
<key>cache_lifetime</key>
</action>
<action method="unsetData">
<key>cache_tags</key>
</action>
</block>
I wondered if anyone could tell me how I could fix this issue? Either by adding actions to the local.xml or by adding PHP to the .phtml file.