I've planned to make a small module which allows the creation of a custom formula. Though I'm a little bit lost at the creation of the admin section. I managed to write a system.xml with sections, groups and fields but I have no idea how to give the user the option to add an element (like adding a new entry for the formula). So I took a look at Grids and those seem to be the right way but also a bit too much for the little task I want to accomplish.

So what's the proper way to give the user the option to add an element with its own variables (e.g title="test", id=1, sort_order=1 etc.)?

2 Answers 2


You can create tables (mini-grids, sort of) in the system configuration, using a custom frontend model that extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract


How it looks

Example table


The field in systeml.xml for this example:

<shipping_costs translate="label">
    <label>Shipping Cost based on Price</label>

Frontend model

Above you have defined a frontend model. You need to create this as a custom block

class Namespace_Module_Block_Config_ShippingCosts 
    extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
    public function _prepareToRender()
        $this->addColumn('from_price', array(
            'label' => Mage::helper('namespace_module')->__('From Price'),
            'style' => 'width:100px',
        $this->addColumn('cost', array(
            'label' => Mage::helper('namespace_module')->__('Shipping Cost'),
            'style' => 'width:100px',

        $this->_addAfter = false;
        $this->_addButtonLabel = Mage::helper('namespace_module')->__('Add');


To use the configured data, you need to unserialize it, like this:

$shippingCosts = Mage::getStoreConfig('namespace_module/general/shipping_costs');
if ($shippingCosts) {
    $shippingCosts = unserialize($shippingCosts);
    if (is_array($shippingCosts)) {
        foreach($shippingCosts as $shippingCostsRow) {
            $fromPrice = $shippingCostsRow['from_price'];
            $cost = $shippingCostsRow['cost'];
    } else {
        // handle unserializing errors here

The example is taken from this tutorial: http://www.integer-net.com/2015/03/17/how-to-create-tables-in-magento-system-configuration/ where the code is explained in more detail.


In the Tabs.php we create for the admin form, there is an addTab() function in which we pass the class’s path, of the forms section we want to add. What we can do is simply, put the class of our grid here.:- example:-

$this->addTab('form_section', array(
     'label'     => Mage::helper('test')->__('Sample Grid'),
     'title'     => Mage::helper('test')->__('Sample Grid'),
     'content'   => $this->getLayout()->createBlock('fav/adminhtml_fav_edit_tab_grid')->toHtml(),

see more:-http://excellencemagentoblog.com/blog/2011/09/07/magento-grid-serializer-admin-tabs-grid/

  • Thanks, I'll check it out. So you would say a grid is the way to go?
    – mpfmon
    Jul 1, 2015 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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