i'm using Magento 1.9.0.1.
I'm trying to display data from a custom MySQL table to a grid table in a custom admin panel page.
Here is the structure of the table from which i want to display the data.
The table is called - VivasIndustries_SmsNotification
:
Right now i have this result:
As you can see no table is created and no data is displayed.
Now i'm going to show you what i have in my extension files:
I have in /app/code/community/VivasIndustries/SmsNotification/etc/config.xml:
<?xml version="1.0"?>
<config>
<modules>
<VivasIndustries_SmsNotification>
<version>0.1.0</version>
</VivasIndustries_SmsNotification>
</modules>
<global>
<models>
<smsnotification>
<class>VivasIndustries_SmsNotification_Model</class>
<resourceModel>vivasindustries_smsnotification_resource</resourceModel>
</smsnotification>
<vivasindustries_smsnotification_resource>
<class>VivasIndustries_SmsNotification_Model_Resource</class>
<entities>
<smsnotification>
<table>VivasIndustries_SmsNotification</table>
</smsnotification>
</entities>
</vivasindustries_smsnotification_resource>
</models>
<resources>
<smsnotification_setup>
<setup>
<module>VivasIndustries_SmsNotification</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</smsnotification_setup>
<smsnotification_read>
<connection>
<use>core_read</use>
</connection>
</smsnotification_read>
<smsnotification_write>
<connection>
<use>core_write</use>
</connection>
</smsnotification_write>
</resources>
<events>
<sales_order_save_after>
<observers>
<vivasindustries_smsnotification>
<class>smsnotification/observer</class>
<method>orderSaved</method>
</vivasindustries_smsnotification>
</observers>
</sales_order_save_after>
</events>
<helpers>
<smsnotification>
<class>VivasIndustries_SmsNotification_Helper</class>
</smsnotification>
</helpers>
<blocks>
<smsnotification>
<class>VivasIndustries_SmsNotification_Block</class>
</smsnotification>
</blocks>
</global>
<adminhtml>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<system>
<children>
<config>
<children>
<vivas>
<title>Vivas - All</title>
</vivas>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</adminhtml>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<VivasIndustries_SmsNotification before="Mage_Adminhtml">VivasIndustries_SmsNotification_Adminhtml</VivasIndustries_SmsNotification>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Here is what i have in: /app/code/community/VivasIndustries/SmsNotification/Model/SmsNotification.php:
<?php
class VivasIndustries_SmsNotification_Model_SmsNotification extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('smsnotification/smsnotification');
}
}
Here is what i have in: /app/code/community/VivasIndustries/SmsNotification/Model/Resource/SmsNotification.php:
<?php
class VivasIndustries_SmsNotification_Model_Resource_SmsNotification extends Mage_Core_Model_Resource_Db_Abstract
{
/**
* Initialize resource model
*
* @return void
*/
public function _construct()
{
$this->_init('smsnotification/smsnotification','id');
}
}
Here is what i have in: /app/code/community/VivasIndustries/SmsNotification/Model/Resource/SmsNotification/Collection.php:
<?php
class VivasIndustries_SmsNotification_Model_Resource_SmsNotification_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract{
protected function _construct(){
$this->_init('smsnotification/smsnotification');
}
}
And last and maybe most important:
Here is what i have in: /app/code/community/VivasIndustries/SmsNotification/Block/Adminhtml/Sales/Status/Grid.php:
<?php
class VivasIndustries_SmsNotification_Block_Adminhtml_Sales_Status_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('smsnotification_grid');
$this->setDefaultSort('id');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
}
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('smsnotification/smsnotification_collection');
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('id', array(
'header' => Mage::helper('smsnotification')->__('ID'),
'align' =>'right',
'width' => '50px',
'index' => 'id',
));
$this->addColumn('Receiver', array(
'header' => Mage::helper('smsnotification')->__('Receiver'),
'align' =>'left',
'index' => 'Receiver',
));
return parent::_prepareColumns();
}
public function getGridUrl()
{
return $this->getUrl('*/*/grid', array('_current'=>true));
}
}
Here is what i have in: /app/code/community/VivasIndustries/SmsNotification/Block/Adminhtml/Sales/Status.php:
<?php
class VivasIndustries_SmsNotification_Block_Adminhtml_Sales_Status extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_blockGroup = 'smsnotification';
$this->_controller = 'adminhtml_sales_status';
$this->_headerText = Mage::helper('smsnotification')->__('Send SMS on Order Status Changes');
parent::__construct();
$this->_removeButton('add');
}
}
Please help me out to display the data from VivasIndustries_SmsNotification
and why now i get blank page, where is my mistake?
Thanks in advance!