Magento Create Custom Module with Custom Database Table

March 11th, 2012 by laeeq | 1 comment

We can create magento custom modules by following the common module structure of Magento.
Here We  have provided all required module sturcture file for creating custom magento modules.

Let’s setup our directory structure:

/app/code/local/<Namespace>/<Module>/

Block/
controllers/
etc/
Model/
Mysql4/
/
sql/
_setup/

Activate Module

Magento requires there to be an XML file that tells Magento to look for and use your custom module.

/app/etc/modules/<Namespace>_<Module>.xml

  1. <?xml version=“1.0″?>
  2. <config>
  3. <modules>
  4. <[Namespace]_[Module]>
  5. <active>true</active>
  6. <codePool>local</codePool>
  7. </[Namespace]_[Module]>
  8. </modules>
  9. </config>

Also you can disable your module in the Configuration menu on the backend via the Advanced tab.

Create Controller

/app/code/local/<Namespace>/<Module>/controllers/IndexController.php

  1. <?php
  2. class <Namespace>_<Module>_IndexController extends Mage_Core_Controller_Front_Action
  3. {
  4. public function indexAction()
  5. {
  6. $this->loadLayout();
  7. $this->renderLayout();
  8. }
  9. }

Create Configuration XML

/app/code/local/<Namespace>/<Module>/etc/config.xml

  1. <?xml version=“1.0″?>
  2. <config>
  3. <modules>
  4. <[Namespace]_[Module]>
  5. <version>0.1.0</version>
  6. </[Namespace]_[Module]>
  7. </modules>
  8. <frontend>
  9. <routers>
  10. <[module]>
  11. <use>standard</use>
  12. <args>
  13. <module>[Namespace]_[Module]</module>
  14. <frontName>[module]</frontName>
  15. </args>
  16. </[module]>
  17. </routers>
  18. <layout>
  19. <updates>
  20. <[module]>
  21. <file>[module].xml</file>
  22. </[module]>
  23. </updates>
  24. </layout>
  25. </frontend>
  26. <global>
  27. <models>
  28. <[module]>
  29. <class>[Namespace]_[Module]_Model</class>
  30. <resourceModel>[module]_mysql4</resourceModel>
  31. </[module]>
  32. <[module]_mysql4>
  33. <class>[Namespace]_[Module]_Model_Mysql4</class>
  34. <entities>
  35. <[module]>
  36. <table>[module]</table>
  37. </[module]>
  38. </entities>
  39. </[module]_mysql4>
  40. </models>
  41. <resources>
  42. <[module]_setup>
  43. <setup>
  44. <module>[Namespace]_[Module]</module>
  45. </setup>
  46. <connection>
  47. <use>core_setup</use>
  48. </connection>
  49. </[module]_setup>
  50. <[module]_write>
  51. <connection>
  52. <use>core_write</use>
  53. </connection>
  54. </[module]_write>
  55. <[module]_read>
  56. <connection>
  57. <use>core_read</use>
  58. </connection>
  59. </[module]_read>
  60. </resources>
  61. <blocks>
  62. <[module]>
  63. <class>[Namespace]_[Module]_Block</class>
  64. </[module]>
  65. </blocks>
  66. <helpers>
  67. <[module]>
  68. <class>[Namespace]_[Module]_Helper</class>
  69. </[module]>
  70. </helpers>
  71. </global>
  72. </config>

Create Helper

/app/code/local/<Namespace>/<Module>/Helper/Data.php

  1. <?php
  2. class <Namespace>_<Module>_Helper_Data extends Mage_Core_Helper_Abstract
  3. {
  4. }

Create Models

If you are quite new to Magento you should pay attention to one of its specifics! The Constructors below are not the usual PHP-Constructors!! Keeping that in mind can save hours of frustrating crashes ;)

/app/code/local/<Namespace>/<Module>/Model/<Module>.php

  1. <?php
  2. class <Namespace>_<Module>_Model_<Module> extends Mage_Core_Model_Abstract
  3. {
  4. public function _construct()
  5. {
  6. parent::_construct();
  7. $this->_init(‘<module>/<module>’);

/app/code/local/<Namespace>/<Module>/Model/Mysql4/<Module>.php

  1. <?php
  2. class <Namespace>_<Module>_Model_Mysql4_<Module> extends Mage_Core_Model_Mysql4_Abstract
  3. {
  4. public function _construct()
  5. {
  6. $this->_init(‘<module>/<module>’, ‘<module>_id’);
  7. }
  8. }

NOTE: The ‘_id’ refers to the PRIMARY KEY in your database table.

/app/code/local/<Namespace>/<Module>/Model/Mysql4/<Module>/Collection.php

  1. <?php
  2. class <Namespace>_<Module>_Model_Mysql4_<Module>_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
  3. {
  4. public function _construct()
  5. {
  6. //parent::__construct();
  7. $this->_init(‘<module>/<module>’);
  8. }
  9. }

SQL Setup

/app/code/local/<Namespace>/<Module>/sql/<module>_setup/mysql4-install-0.1.0.php

  1. <?php
  2. $installer = $this;
  3. $installer->startSetup();
  4. $installer->run(”
  5. – DROP TABLE IF EXISTS {$this->getTable(‘<module>’)};
  6. CREATE TABLE {$this->getTable(‘<module>’)} (
  7. `<module>_id` int(11) unsigned NOT NULL auto_increment,
  8. `title` varchar(255) NOT NULL default ,
  9. `content` text NOT NULL default ,
  10. `status` smallint(6) NOT NULL default ’0′,
  11. `created_time` datetime NULL,
  12. `update_time` datetime NULL,
  13. PRIMARY KEY (`<module>_id`)
  14. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  15. “);
  16. $installer->endSetup();

NOTE: Please note the text that needs to be replaced. This SQL structure is up to you, this is merely a starting point.

Note Important: If you add fields and couldn’t save data in these fields please try to go to System?Cache Management Then 1.Flush Cache Storage 2.Flush Magento Cache.

Template Design

/app/design/frontend/<interface>/<theme>/layout/<module>.xml

/layout/.xml

  1. <?xml version=“1.0″?>
  2. <layout version=“0.1.0″>
  3. <[module]_index_index>
  4. <reference name=“content”>
  5. <block type=“[module]/[module]“ name=“[module]“ />
  6. </reference>
  7. </[module]_index_index>
  8. </layout>

NOTE: The block type will automatically figure out what template file to use based on the second [module] declaration.

As an alternate way of declaring what template file to use you can use this:

/app/design/frontend/<interface>/<theme>/layout/<module>.xml

  1. <?xml version=“1.0″?>
  2. <layout version=“0.1.0″>
  3. <[module]_index_index>
  4. <reference name=“content”>
  5. <block type=“core/template” name=“[module]“ template=“[module]/[module].phtml” />
  6. </reference>
  7. </[module]_index_index>
  8. </layout>

/app/design/frontend/<interface>/<theme>/template/<module>/<module>.phtml

  1. <h4><?php echo $this->__(‘Module List’) ?></h4>
  2. <?php
  3. /*
  4. This will load one record from your database table.
  5. load(<module>_id) will load whatever ID number you give it.
  6. */
  7. /*
  8. $news = Mage::getModel(‘<module>/<module>’)->load(1);
  9. echo $news->get<Module>Id();
  10. echo $news->getTitle();
  11. echo $news->getContent();
  12. echo $news->getStatus();
  13. */
  14. /*
  15. This block of code loads all of the records in the database table.
  16. It will iterate through the collection and the first thing it will do
  17. is set the Title to the current value of $i which is incremented each
  18. iteration and then echo that value back out.  At the very end it will
  19. save the entire collection.
  20. */
  21. /*
  22. $i = 0;
  23. $collection = Mage::getModel(‘<module>/<module>’)->getCollection();
  24. $collection->setPageSize(5);
  25. $collection->setCurPage(2);
  26. $size = $collection->getSize();
  27. $cnt = count($collection);
  28. foreach ($collection as $item) {
  29. $i = $i+1;
  30. $item->setTitle($i);
  31. echo $item->getTitle();
  32. }
  33. $collection->walk(‘save’);
  34. */
  35. /*
  36. This shows how to load one value, change something and save it.
  37. */
  38. /*
  39. $object = Mage::getModel(‘<module>/<module>’)->load(1);
  40. $object->setTitle(‘This is a changed title’);
  41. $object->save();
  42. */
  43. ?>

Directory Additions
Here is the revised directory setup due to the additions and changes we need for the backend module.

/app/code/local/<Namespace>/<Module>/

Block/
Adminhtml/
/
Edit/
Tab/
controllers/
Adminhtml/
etc/
Helper/
Model/
Mysql4/
/
sql/
_setup/

Blocks

These control the setup and appearance of your grids and the options that they display.

NOTE: Please note the fact that Block comes before Adminhtml in the class declaration. In any of the Magento modules in Adminhtml it is the opposite. For your module to work it has to be Block_Adminhtml otherwise you will get a ‘Cannot redeclare module…’ error.

/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>.php

  1. <?php
  2. class <Namespace>_<Module>_Block_Adminhtml_<Module> extends Mage_Adminhtml_Block_Widget_Grid_Container
  3. {
  4. public function __construct()
  5. {
  6. $this->_controller = ‘adminhtml_<module>’;
  7. $this->_blockGroup = ‘<module>’;
  8. $this->_headerText = Mage::helper(‘<module>’)->__(‘Item Manager’);
  9. $this->_addButtonLabel = Mage::helper(‘<module>’)->__(‘Add Item’);
  10. parent::__construct();
  11. }
  12. }

/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit.php

  1. <?php
  2. class <Namespace>_<Module>_Block_Adminhtml_<Module>_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->_objectId = ‘id’;
  8. $this->_blockGroup = ‘<module>’;
  9. $this->_controller = ‘adminhtml_<module>’;
  10. $this->_updateButton(‘save’, ‘label’, Mage::helper(‘<module>’)->__(‘Save Item’));
  11. $this->_updateButton(‘delete’, ‘label’, Mage::helper(‘<module>’)->__(‘Delete Item’));
  12. }
  13. public function getHeaderText()
  14. {
  15. if( Mage::registry(‘<module>_data’) && Mage::registry(‘<module>_data’)->getId() ) {
  16. return Mage::helper(‘<module>’)->__(“Edit Item ’%s’”, $this->htmlEscape(Mage::registry(‘<module>_data’)->getTitle()));
  17. else {
  18. return Mage::helper(‘<module>’)->__(‘Add Item’);
  19. }
  20. }
  21. }

/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Grid.php

  1. <?php
  2. class <Namespace>_<Module>_Block_Adminhtml_<Module>_Grid extends Mage_Adminhtml_Block_Widget_Grid
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->setId(‘<module>Grid’);
  8. // This is the primary key of the database
  9. $this->setDefaultSort(‘<module>_id’);
  10. $this->setDefaultDir(‘ASC’);
  11. $this->setSaveParametersInSession(true);
  12. }
  13. protected function _prepareCollection()
  14. {
  15. $collection = Mage::getModel(‘<module>/<module>’)->getCollection();
  16. $this->setCollection($collection);
  17. return parent::_prepareCollection();
  18. }
  19. protected function _prepareColumns()
  20. {
  21. $this->addColumn(‘<module>_id’, array(
  22. ‘header’ => Mage::helper(‘<module>’)->__(‘ID’),
  23. ‘align’ =>‘right’,
  24. ‘width’ => ’50px’,
  25. ‘index’ => ‘<module>_id’,
  26. ));
  27. $this->addColumn(‘title’, array(
  28. ‘header’ => Mage::helper(‘<module>’)->__(‘Title’),
  29. ‘align’ =>‘left’,
  30. ‘index’ => ‘title’,
  31. ));
  32. /*
  33. $this->addColumn(‘content’, array(
  34. ‘header’    => Mage::helper(‘<module>’)->__(‘Item Content’),
  35. ‘width’     => ’150px’,
  36. ‘index’     => ’content’,
  37. ));
  38. */
  39. $this->addColumn(‘created_time’, array(
  40. ‘header’ => Mage::helper(‘<module>’)->__(‘Creation Time’),
  41. ‘align’ => ‘left’,
  42. ‘width’ => ’120px’,
  43. ‘type’ => ‘date’,
  44. ‘default’ => ‘–’,
  45. ‘index’ => ‘created_time’,
  46. ));
  47. $this->addColumn(‘update_time’, array(
  48. ‘header’ => Mage::helper(‘<module>’)->__(‘Update Time’),
  49. ‘align’ => ‘left’,
  50. ‘width’ => ’120px’,
  51. ‘type’ => ‘date’,
  52. ‘default’ => ‘–’,
  53. ‘index’ => ‘update_time’,
  54. ));
  55. $this->addColumn(‘status’, array(
  56. ‘header’ => Mage::helper(‘<module>’)->__(‘Status’),
  57. ‘align’ => ‘left’,
  58. ‘width’ => ’80px’,
  59. ‘index’ => ‘status’,
  60. ‘type’ => ‘options’,
  61. ‘options’ => array(
  62. 1 => ‘Active’,
  63. 0 => ‘Inactive’,
  64. ),
  65. ));
  66. return parent::_prepareColumns();
  67. }
  68. public function getRowUrl($row)
  69. {
  70. return $this->getUrl(‘*/*/edit’, array(‘id’ => $row->getId()));
  71. }
  72. }

/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit/Form.php

  1. <?php
  2. class <Namespace>_<Module>_Block_Adminhtml_<Module>_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
  3. {
  4. protected function _prepareForm()
  5. {
  6. $form = new Varien_Data_Form(array(
  7. ‘id’ => ‘edit_form’,
  8. ‘action’ => $this->getUrl(‘*/*/save’, array(‘id’ => $this->getRequest()->getParam(‘id’))),
  9. ‘method’ => ‘post’,
  10. )
  11. );
  12. $form->setUseContainer(true);
  13. $this->setForm($form);
  14. return parent::_prepareForm();
  15. }
  16. }

/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit/Tabs.php

  1. <?php
  2. class <Namespace>_<Module>_Block_Adminhtml_<Module>_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->setId(‘<module>_tabs’);
  8. $this->setDestElementId(‘edit_form’);
  9. $this->setTitle(Mage::helper(‘<module>’)->__(‘News Information’));
  10. }
  11. protected function _beforeToHtml()
  12. {
  13. $this->addTab(‘form_section’, array(
  14. ‘label’ => Mage::helper(‘<module>’)->__(‘Item Information’),
  15. ‘title’ => Mage::helper(‘<module>’)->__(‘Item Information’),
  16. ‘content’ => $this->getLayout()->createBlock(‘<module>/adminhtml_<module>_edit_tab_form’)->toHtml(),
  17. ));
  18. return parent::_beforeToHtml();
  19. }
  20. }

/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit/Tab/Form.php

  1. <?php
  2. class <Namespace>_<Module>_Block_Adminhtml_<Module>_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
  3. {
  4. protected function _prepareForm()
  5. {
  6. $form = new Varien_Data_Form();
  7. $this->setForm($form);
  8. $fieldset = $form->addFieldset(‘<module>_form’, array(‘legend’=>Mage::helper(‘<module>’)->__(‘Item information’)));
  9. $fieldset->addField(‘title’, ‘text’, array(
  10. ‘label’ => Mage::helper(‘<module>’)->__(‘Title’),
  11. ‘class’ => ‘required-entry’,
  12. ‘required’ => true,
  13. ‘name’ => ‘title’,
  14. ));
  15. $fieldset->addField(‘status’, ‘select’, array(
  16. ‘label’ => Mage::helper(‘<module>’)->__(‘Status’),
  17. ‘name’ => ‘status’,
  18. ‘values’ => array(
  19. array(
  20. ‘value’ => 1,
  21. ‘label’ => Mage::helper(‘<module>’)->__(‘Active’),
  22. ),
  23. array(
  24. ‘value’ => 0,
  25. ‘label’ => Mage::helper(‘<module>’)->__(‘Inactive’),
  26. ),
  27. ),
  28. ));
  29. $fieldset->addField(‘content’, ‘editor’, array(
  30. ‘name’ => ‘content’,
  31. ‘label’ => Mage::helper(‘<module>’)->__(‘Content’),
  32. ‘title’ => Mage::helper(‘<module>’)->__(‘Content’),
  33. ‘style’ => ‘width:98%; height:400px;’,
  34. ‘wysiwyg’ => false,
  35. ‘required’ => true,
  36. ));
  37. if ( Mage::getSingleton(‘adminhtml/session’)->get<Module>Data() )
  38. {
  39. $form->setValues(Mage::getSingleton(‘adminhtml/session’)->get<Module>Data());
  40. Mage::getSingleton(‘adminhtml/session’)->set<Module>Data(null);
  41. } elseif ( Mage::registry(‘<module>_data’) ) {
  42. $form->setValues(Mage::registry(‘<module>_data’)->getData());
  43. }
  44. return parent::_prepareForm();
  45. }
  46. }

Controller

/app/code/local/<Namespace>/<Module>/controllers/Adminhtml/<Module>Controller.php

  1. <?php
  2. class <Namespace>_<Module>_Adminhtml_<Module>Controller extends Mage_Adminhtml_Controller_Action
  3. {
  4. protected function _initAction()
  5. {
  6. $this->loadLayout()
  7. ->_setActiveMenu(‘<module>/items’)
  8. ->_addBreadcrumb(Mage::helper(‘adminhtml’)->__(‘Items Manager’), Mage::helper(‘adminhtml’)->__(‘Item Manager’));
  9. return $this;
  10. }
  11. public function indexAction() {
  12. $this->_initAction();
  13. $this->_addContent($this->getLayout()->createBlock(‘<module>/adminhtml_<module>’));
  14. $this->renderLayout();
  15. }
  16. public function editAction()
  17. {
  18. $<module>Id     = $this->getRequest()->getParam(‘id’);
  19. $<module>Model  = Mage::getModel(‘<module>/<module>’)->load($<module>Id);
  20. if ($<module>Model->getId() || $<module>Id == 0) {
  21. Mage::register(‘<module>_data’, $<module>Model);
  22. $this->loadLayout();
  23. $this->_setActiveMenu(‘<module>/items’);
  24. $this->_addBreadcrumb(Mage::helper(‘adminhtml’)->__(‘Item Manager’), Mage::helper(‘adminhtml’)->__(‘Item Manager’));
  25. $this->_addBreadcrumb(Mage::helper(‘adminhtml’)->__(‘Item News’), Mage::helper(‘adminhtml’)->__(‘Item News’));
  26. $this->getLayout()->getBlock(‘head’)->setCanLoadExtJs(true);
  27. $this->_addContent($this->getLayout()->createBlock(‘<module>/adminhtml_<module>_edit’))
  28. ->_addLeft($this->getLayout()->createBlock(‘<module>/adminhtml_<module>_edit_tabs’));
  29. $this->renderLayout();
  30. else {
  31. Mage::getSingleton(‘adminhtml/session’)->addError(Mage::helper(‘<module>’)->__(‘Item does not exist’));
  32. $this->_redirect(‘*/*/’);
  33. }
  34. }
  35. public function newAction()
  36. {
  37. $this->_forward(‘edit’);
  38. }
  39. public function saveAction()
  40. {
  41. if ( $this->getRequest()->getPost() ) {
  42. try {
  43. $postData = $this->getRequest()->getPost();
  44. $<module>Model = Mage::getModel(‘<module>/<module>’);
  45. $<module>Model->setId($this->getRequest()->getParam(‘id’))
  46. ->setTitle($postData['title'])
  47. ->setContent($postData['content'])
  48. ->setStatus($postData['status'])
  49. ->save();
  50. Mage::getSingleton(‘adminhtml/session’)->addSuccess(Mage::helper(‘adminhtml’)->__(‘Item was successfully saved’));
  51. Mage::getSingleton(‘adminhtml/session’)->set<Module>Data(false);
  52. $this->_redirect(‘*/*/’);
  53. return;
  54. catch (Exception $e) {
  55. Mage::getSingleton(‘adminhtml/session’)->addError($e->getMessage());
  56. Mage::getSingleton(‘adminhtml/session’)->set<Module>Data($this->getRequest()->getPost());
  57. $this->_redirect(‘*/*/edit’, array(‘id’ => $this->getRequest()->getParam(‘id’)));
  58. return;
  59. }
  60. }
  61. $this->_redirect(‘*/*/’);
  62. }
  63. public function deleteAction()
  64. {
  65. if( $this->getRequest()->getParam(‘id’) > 0 ) {
  66. try {
  67. $<module>Model = Mage::getModel(‘<module>/<module>’);
  68. $<module>Model->setId($this->getRequest()->getParam(‘id’))
  69. ->delete();
  70. Mage::getSingleton(‘adminhtml/session’)->addSuccess(Mage::helper(‘adminhtml’)->__(‘Item was successfully deleted’));
  71. $this->_redirect(‘*/*/’);
  72. catch (Exception $e) {
  73. Mage::getSingleton(‘adminhtml/session’)->addError($e->getMessage());
  74. $this->_redirect(‘*/*/edit’, array(‘id’ => $this->getRequest()->getParam(‘id’)));
  75. }
  76. }
  77. $this->_redirect(‘*/*/’);
  78. }
  79. /**
  80. * Product grid for AJAX request.
  81. * Sort and filter result for example.
  82. */
  83. public function gridAction()
  84. {
  85. $this->loadLayout();
  86. $this->getResponse()->setBody(
  87. $this->getLayout()->createBlock(‘importedit/adminhtml_<module>_grid’)->toHtml()
  88. );
  89. }
  90. }

XML Configuration Changes

/app/code/local/<Namespace>/<Module>/etc/config.xml

  1. <?xml version=“1.0″?>
  2. <config>
  3. <modules>
  4. <[Namespace]_[Module]>
  5. <version>0.1.0</version>
  6. </[Namespace]_[Module]>
  7. </modules>
  8. <frontend>
  9. <routers>
  10. <[module]>
  11. <use>standard</use>
  12. <args>
  13. <module>[Namespace]_[Module]</module>
  14. <frontName>[module]</frontName>
  15. </args>
  16. </[module]>
  17. </routers>
  18. <layout>
  19. <updates>
  20. <[module]>
  21. <file>[module].xml</file>
  22. </[module]>
  23. </updates>
  24. </layout>
  25. </frontend>
  26. <admin>
  27. <routers>
  28. <[module]>
  29. <use>admin</use>
  30. <args>
  31. <module>[Namespace]_[Module]</module>
  32. <frontName>[module]</frontName>
  33. </args>
  34. </[module]>
  35. </routers>
  36. </admin>
  37. <adminhtml>
  38. <menu>
  39. <[module] module=“[module]“>
  40. <title>[Module]</title>
  41. <sort_order>71</sort_order>
  42. <children>
  43. <items module=“[module]“>
  44. <title>Manage Items</title>
  45. <sort_order>0</sort_order>
  46. <action>[module]/adminhtml_[module]</action>
  47. </items>
  48. </children>
  49. </[module]>
  50. </menu>
  51. <acl>
  52. <resources>
  53. <all>
  54. <title>Allow Everything</title>
  55. </all>
  56. <admin>
  57. <children>
  58. <[module]>
  59. <title>[Module] Module</title>
  60. <sort_order>200</sort_order>
  61. </[module]>
  62. </children>
  63. </admin>
  64. </resources>
  65. </acl>
  66. <layout>
  67. <updates>
  68. <[module]>
  69. <file>[module].xml</file>
  70. </[module]>
  71. </updates>
  72. </layout>
  73. </adminhtml>
  74. <global>
  75. <models>
  76. <[module]>
  77. <class>[Namespace]_[Module]_Model</class>
  78. <resourceModel>[module]_mysql4</resourceModel>
  79. </[module]>
  80. <[module]_mysql4>
  81. <class>[Namespace]_[Module]_Model_Mysql4</class>
  82. <entities>
  83. <[module]>
  84. <table>[module]</table>
  85. </[module]>
  86. </entities>
  87. </[module]_mysql4>
  88. </models>
  89. <resources>
  90. <[module]_setup>
  91. <setup>
  92. <module>[Namespace]_[Module]</module>
  93. </setup>
  94. <connection>
  95. <use>core_setup</use>
  96. </connection>
  97. </[module]_setup>
  98. <[module]_write>
  99. <connection>
  100. <use>core_write</use>
  101. </connection>
  102. </[module]_write>
  103. <[module]_read>
  104. <connection>
  105. <use>core_read</use>
  106. </connection>
  107. </[module]_read>
  108. </resources>
  109. <blocks>
  110. <[module]>
  111. <class>[Namespace]_[Module]_Block</class>
  112. </[module]>
  113. </blocks>
  114. <helpers>
  115. <[module]>
  116. <class>[Namespace]_[Module]_Helper</class>
  117. </[module]>
  118. </helpers>
  119. </global>
  120. </config>

XML Layout

/app/design/adminhtml/<interface>/<theme>/layout/<module>.xml

  1. <?xml version=“1.0″?>
  2. <layout version=“0.1.0″>
  3. <[module]_adminhtml_[module]_index>
  4. <reference name=“content”>
  5. <block type=“[module]/adminhtml_[module]“ name=“[module]“ />
  6. </reference>
  7. </[module]_adminhtml_[module]_index>
  8. </layout>

You can subscribe to PHPZAG.COM posts by Email

 

Related Topics:

  • Get an array of billing addresses and shipping addresses in Magento
  • Duplicate Data Issue with Custom Magento Collection
  • Tips To Improve Your Ecommerce Site’s Security
  • Magento: Display New Products from Specific Category On Home Page
  • Dealing with Magento Model or Collections
  • Magento: Display New Products On Home Page
  • Magento: Display More Than 5 New Products
  • Override Controllers in Magento
  • Improve the performance of your Magento store
  • Magento Released Community Edition 1.7.0.1
  • Write custom title, keywords and description in Magento module
  • Moving Magento site from development to live server
  • Display Related products on product details page in Magento
  • Magento – Models, resource models, and collections
  • Magento – Add thumbnail images to Magento admin grid
  • Simple url rewrite in magento
  • Generate CSV file in Magento
  • Resize image in Magento using Varien_Image class
  • AJAX requests in Magento
  • Category Navigation Listings in Magento
  •  

     

    1. July 10th, 2012 at 12:14 | #1

      hello i use your post and i want to show at home page then it’s displaying error fatal error(Fatal error: Call to a member function load() )

    1. No trackbacks yet.