I'm using Magento

Right now i'm working on a custom extension for Magento and i need to know how to get the data from a custom MySQL table into a table in custom admin panel page.

I've already added a custom page in the admin panel, here it is:

enter image description here

Here is the code of this page /app/design/adminhtml/default/default/template/vivasindustries/smsnotification/about.phtml:

<h2> Hi there</h2>
This is new custom page where i must add a grid table!

In this page i want to add a grid table like this one:

enter image description here

This is just an example of what kind of table i need. In this table there must be in first time so i can understand how the things work only 3 cells - Receiver,Phone and Date which is fetching data from my custom MySQL table VivasIndustries_SmsNotification.

Here is a picture from the phpMyAdmin so you can see the structure of the table VivasIndustries_SmsNotification:

enter image description here

So at final i want to say that i want this data to be snown in my custom admin page a grid table..

Please help me out to make this thing.

Thanks in advance!


You need to add a grid container and the grid itself (For an example see Mage_Adminhtml_Block_Sales_Order and Mage_Adminhtml_Block_Sales_Order_Grid). The important method for your case is _prepareCollection in the grid class. That's the place where you have to build your query for fetching the data. Furthermore you have to define the columns of the grid in _prepareColumns method. The index-field of the array passed to addColumn must be a index of the collection. I assume that you have created the model, resource model and collection model for accessing the data from the database. One last thing is to create a layout handle in order to add the grid container to the layout.

Not the answer you're looking for? Browse other questions tagged or ask your own question.