The goal is to append a block, after the product price, on the product view page using an observer.
To this moment, I was able to:
- clone the catalog/product_price
- set the clone as a child-block
- and set a custom type and template for it
The issue is, that there are additional blocks on the page, that include a catalog/product_price block. Tier-prices and related products namely. I would like exclude them from the block cloning and child addition process.
the relevant config.xml part:
<frontend>
<events>
<core_block_abstract_to_html_before>
<observers>
<namespace_modulename>
<type>model</type>
<class>namespace_modulename/observer</class>
<method>insertBlock</method>
</namespace_modulename>
</observers>
</core_block_abstract_to_html_before>
</events>
</frontend>
the observer:
class Namespace_Modulename_Model_Observer {
public function insertBlock($observer){
$_block = $observer->getBlock();
$_type = $_block->getType();
if ($_type == 'catalog/product_price') {
$_child = clone $_block;
$_child->setType('some/block');
$_block->setChild('kiddo', $_child);
$_block->setTemplate('namespace/modulname/additional.phtml');
}
}
}
How would you advise to do that, preferably in canonical Magento API way ?
config.xml
. Put your layout xml underbase/default
which all themes fallback to and it will always be applied (and thus be theme independent).