Magento Grid Container Block not loading grid
Asked Answered
N

1

6

I just set up an admin module with a grid view using the module creator, and it works great, but now I need to add another grid view within the same module.

I copied and renamed all the files relevant to the grid view(controllers and block files, but not models, as they are not needed for what I'm doing) , and added the newly created block to the layout xml under the handle for it's new controller.

Using Firephp, I've worked out that everything loads fine for my new view up until the Grid.php which doesn't load, and the end output is just a blank page.

As far as I'm aware, this new view is identical to the original working grid view generated by the module in all aspects except name, so what could be causing it to not recognize or load the Grid.php?

Nickname answered 19/4, 2011 at 12:47 Comment(0)
D
19

In the grid container block look at the values for $_blockGroup and $_controller. These are used by the container to find and load the grid block. If you really want to see what is going on look at the parent::_prepareLayout() method.

PS:
$_blockGroup is your module's name.
$_controller is the path to your grid block.

PPS:
If that's not enough put this in your .htaccess:

php_flag display_errors on
SetEnv MAGE_IS_DEVELOPER_MODE true

You should get a lot more information if the grid is having problems with it's collection's SQL or something.

Delay answered 19/4, 2011 at 12:57 Comment(7)
These are all set in the block. Interestingly, if I set $_blockGroup to that of the original view, it loads the original view's grid fine. Is _blockGroup simply referring to the folder name in the block folder where the grid is, or is this defined somewhere else?Nickname
I've just looked through the error logs on the server, and I'm getting the following error: Call to a member function setSaveParametersInSession() on a non-objectNickname
I got the names back to front and didn't realise until I looked closer at the _prepareLayout method, _blockGroup is NOT the folder name. If _blockGroup is yourmodule and _controller is example then it will try to load the class Your_Module_Block_Example_Grid. If that class doesn't exist you will see the setSaveParametersInSession() problem.Delay
Resolved! I set blockgroup to the modulename instead of the foldername (which was the same in the example I was copying, hence the confusion), and it runs fine. Thanks for your helpNickname
@Delay "You are right, _blockGroup is the folder name." Well, which folder still remains unclear. And how much of the folder structure?Irresolvable
@Irresolvable See my comment after that one, I got it wrong and the opposite is true.Delay
I found this very useful and tested myself for this kind of problems magento.stackexchange.com/questions/10848/…Lur

© 2022 - 2024 — McMap. All rights reserved.