0

I want to override Magento block Order_Grid, but Magento don't recognize my class.

/app/etc/modules/Octo_OrderGrid.xml

<?xml version="1.0"?> <config> <modules> <Octo_OrderGrid> <active>true</active> <codePool>local</codePool> </Octo_OrderGrid> </modules> </config> 

/app/code/local/Octo/OrderGrid/etc/config.xml

<?xml version="1.0" encoding="utf-8"?> <config> <modules> <Octo_OrderGrid> <version>1.0</version> </Octo_OrderGrid> </modules> <global> <blocks> <adminhtml> <rewrite> <sales_order_grid>Octo_OrderGrid_Adminhtml_Block_Sales_Order_Grid</sales_order_grid> </rewrite> </adminhtml> </blocks> </global> </config> 

/app/code/local/Octo/OrderGrid/Adminhtml/Block/Sales/Order/Grid.php

class Octo_OrderGrid_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid { //Some code } 

This are my three files, I followed instructions on some questions I found on this site, step by step, but again I couldn't make it work.

I can override when I put php file in /app/code/local/Mage/... but that is not what I want.

I use Magento 1.7

1 Answer 1

0

Try this below.

<?xml version="1.0"?> <config> <modules> <Octo_OrderGrid> <version>0.1.0</version> </Octo_OrderGrid> </modules> <global> <helpers> <ordergrid> <class>Octo_OrderGrid_Helper</class> </ordergrid> </helpers> <blocks> <ordergrid> <class>Octo_OrderGrid_Block</class> </ordergrid> <adminhtml> <rewrite> <sales_order_grid>Octo_OrderGrid_Block_Adminhtml_Sales_Order_Grid</sales_order_grid> </rewrite> </adminhtml> </blocks> </global> </config> 

You are missing this inside blocks. You are not defining the block class name.

<ordergrid> <class>Octo_OrderGrid_Block</class> </ordergrid> 

Now create a file named Grid.php inside this path app\code\local\Octo\OrderGrid\Block\Adminhtml\Sales\Order And put the below code there.

<?php class Octo_OrderGrid_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid { } 
7
  • don't work :( I don't even get any errors, just nothing happens Commented Apr 7, 2017 at 11:44
  • Have you changed the block file path? Commented Apr 7, 2017 at 12:08
  • yes, I changed file path Commented Apr 7, 2017 at 12:10
  • Try to add an echo and exit inside the block class and check if the execution goes inside that. Commented Apr 7, 2017 at 12:13
  • tried, nothing happens, it doesn't even read that page :( Commented Apr 7, 2017 at 12:15

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.