Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to override magento blocks

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 106
    Comment on it

    In this blog tutorial, i will explain how to override magento blocks using an XML- based configuration file. Config.xml is module configuration file in which we will override magento block.
    As magento best practices, we should not change any core files to implement custom features because it is a bad programming if core files are modified.

    Create config.xml file of custom module.
    Path: "app/code/local/My/Pant/etc/config.xml" and paste the following contents in that file.

    <config>
    
     <global>
    
          <blocks>
    
               <catalog>
    
                <rewrite>
    
                 <view>My_Pant_Block_View</view>
    
                </rewrite>
    
               </catalog>
    
        </blocks>
    
     </global>
    
    </config>


    Now, create a block file "app/code/local/My/Pant/block/View.php" and paste the following contents in that file.

    class My_Pant_Block_View extends Mage_Catalog_Block_Category_View
    
    {
    
    public function getProductListHtml()
    
      {
    
    
        return $this>getChildHtml('product_list');
    
      }
    
    }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: