Every time a developer has to display information from database tables on Magento admin, she has to write the same code again and again. Magehack_Autogrid can do most of the work for you, as long as the grid is dealing with a flat table.
Every time a developer has to display information from database tables on Magento admin, she has to write the same code again and again. Magehack_Autogrid does most of the work automatically, as long as the grid is dealing with a flat table.
It only requires a potentially very small config file (like, 5 lines of XML excluding the root node), and the rest is taken care of automatically.
This code belongs in a file called etc/autogrid.xml in a modules directory.
<config>
<tables>
<example_product_table>
<table>catalog/product</table>
</example_product_table>
</tables>
</config>
Additional options can be specified of course, overriding the defaults:
<config>
<tables>
<example_product_table>
<table>catalog/product</table>
<title>Autogrid Example Table</title>
<grid>
<entity_type_id>
<sortable>0</sortable>
</entity_type_id>
<has_options>
<source_model>magehack_autogrid/table_column_source_yesno</source_model>
</has_options>
<type_id>
<header>The Product Type</header>
</type_id>
</grid>
<form>
<type_id>
<disabled>1</disabled>
</type_id>
</form>
</example_product_table>
</tables>
</config>
Please have a look at the examples in the etc/autogrid.xml file for more examples.
Also, global defaults based on column name can be specified in the usual config.xml files:
<config>
<adminhtml>
<autogrid>
<column_defaults>
<attribute_set_id>
<frontend_input>select</frontend_input>
<source_model>magehack_autogrid/table_column_source_attributeSetId</source_model>
</attribute_set_id>
<website_ids>
<frontend_input>multiselect</frontend_input>
<source_model>magehack_autogrid/table_column_source_websiteId</source_model>
</website_ids>
<created_at>
<disabled>1</disabled>
</created_at>
</column_defaults>
</autogrid>
</adminhtml>
</config>
There are a number of nice features, for example backend model support for flat table entities.
<config>
<tables>
<example_product_table>
<form>
<updated_at>
<backend_model>magehack_autogrid/table_column_backend_updatedAt</backend_model>
</updated_at>
</form>
</example_product_table>
</tables>
</config>
The extensions source still shows its roots in a one-night hackathon, but work has continued and it is in a usable and rather maintainable state.
Plenty of work can still be done
The module will reading the database table and guess default behaviour for grid (and soon also the form.
If you are using the Magento compiler, disable compilation before the installation, and after the module is installed, you need to run the compiler again.
Here a list of the todo items that I've got in my mind at the moment:
If you have any issues with this extension, open an issue on GitHub (see URL above)
Any contributions are highly appreciated. The best way to contribute code is to open a pull request on GitHub.