Well, We created a very simple custom module that will override the core product listing block (app/code/core/Mage/Catalog/Block/Category/View.php) in the category known as page view.
Our first step should be to create one module file. Create a file ‘app/etc/modules/Namespace_Catalog.xml’ and paste the below content into that file:
1 2 3 4 5 6 7 8 9 |
<?xml version="1.0"?> <config> <modules> <Namespace_Catalog> <active>true</active> <codePool>local</codePool> </Namespace_Catalog> </modules> </config> |
Next, we have to create a module configuration file. Create “app/code/local/Namespace/Catalog/etc/config.xml” and paste the below contents in that file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?xml version="1.0"?> <config> <modules> <Namespace_Catalog> <version>1.0</version> </Namespace_Catalog> </modules> <global> <blocks> <catalog> <rewrite> <category_view>Namespace_Catalog_Block_Category_View</category_view> </rewrite> </catalog> </blocks> </global> </config> |
At the starting point of module, we’ve done a set-up of the module’s version no. by using <version> tag. Following to it, the <catalog> and <rewrite> tags are utilized to override. So Magento system knows that we’re going to override one of the “blocks” of the “Catalog” core module.
The <category_view> tag is utilized to define the identity of the block and that will be overridden by the Namespace_Catalog_Block_Category_View class. It’s mapped to a block file “Category/View.php” under the “Block” directory of the Catalog module.
The last step will be to define a block class Namespace_Catalog_Block_Category_View. Let’s create a block file “app/code/local/Namespace/Catalog/Block/Category/View.php” and paste the below code in that file:
1 2 3 4 5 6 7 8 9 |
<?php class Namespace_Catalog_Block_Category_View extends Mage_Catalog_Block_Category_View { public function getProductListHtml() { /** Your Custom Code Goes Here **/ return $this>getChildHtml('product_list'); } } |
We have defined the Namespace_Catalog_Block_Category_View class which extends the core Mage_Catalog_Block_Category_View block class. Thus, you can easily override the method of the base class and create new methods when required.
[crayon-63d3d3632ff40961302892/] 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.