magehack/autogrid

The Magehack_Autogrid can do most of the work for your simple or more complex grids.

1.0.0 2017-02-13 12:50 UTC

This package is auto-updated.

Last update: 2024-04-22 01:50:21 UTC


README

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.

Facts

Description

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>

Extension Stability

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

Usage

  1. Install the Magehack_Autogrid module
  2. Create the table in your module as usual using a setup script
  3. Create the autogrid.xml file in your modules etc/ directory (syntax is coming soon)

The module will reading the database table and guess default behaviour for grid (and soon also the form.

Compatibility

  • Magento >= 1.7 (probably also earlier)

Installation Instructions

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.

  1. Install the extension from github (its not on Magento Connect).
  2. Clear the cache, logout from the admin panel and then login again.

Todo

Here a list of the todo items that I've got in my mind at the moment:

  • add per table acl resource support
  • add more tests
  • refactor column class further, column types should be individual classes based on an abstract column type
  • complete "all-tables" grid support (view selected tables, create, edit and delete for table contents)
  • remove the example autogrid.xml
  • create examples

Support

If you have any issues with this extension, open an issue on GitHub (see URL above)

Contribution

Any contributions are highly appreciated. The best way to contribute code is to open a pull request on GitHub.

Developers

Licence

OSL - Open Software Licence 3.0