We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    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:

    <?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.

    <?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:

    <?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.

    Fill the below form if you need any Magento relate help/advise/consulting.

    With Only Agency that provides a 24/7 emergency support.

      Get a Free Quote