If you want to add a block after the price on the category page, and for this implementation, you can use the observer core_block_abstract_to_html_before.
You can implement the logic with the below steps:
File path: app/code/local/{namespace}/{yourmodule}/etc/config.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?xml version="1.0"?> <config> <global> <!-- ... --> <models> <namespace_modulename> <class>Namespace_Modulename_Model</class> </namespace_modulename> </models> </global> <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> </config> |
The next step is creating the observer and your template file.
File path: app/code/local/{namespace}/{yourmodule}/Model/Observer.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?php class Namespace_Modulename_Model_Observer { public function insertBlock($observer) { /** @var $_block Mage_Core_Block_Abstract */ /*Get block instance*/ $_block = $observer->getBlock(); /*get Block type*/ $_type = $_block->getType(); /*Check block type*/ if ($_type == 'catalog/product_price') { /*Clone block instance*/ $_child = clone $_block; /*set another type for block*/ $_child->setType('test/block'); /*set child for block*/ $_block->setChild('child', $_child); /*set our template*/ $_block->setTemplate('filename.phtml'); } } } ?> |
You can add the template to app/design/frontend/<package>/<theme>/filename.phtml .
And finally, here is a template filename.phtml code:
1 |
<?php echo $this->getChildHtml('child') ?> |
[crayon-63d3e7f9c04ea830180541/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.