Skip to main content

Looking at Magerun – Drush style commands in Magento

Aug 15 '14

Drush. It’s what makes Drupal truly great. As advocated over and over (and over!), being able to modify variables and run custom scripts on the fly makes Drupal outrageously flexible. Combined with aliases for different environments, drush is an invaluable asset to Drupal. Need a specific variable set on the live server?

drush vset myvar value

And you’re done. Of course, your application will need to know to look for your variable, but with a little forethought in your application development, you can have unlimited control over your application.

But what about Magento? Is there something similar to drush to allow the same granular control over our Magento application? For example - your supplier has alerted you that one of your products (id 57789) has a defect, and you need to disable it:

mash dis 57789

Fortunately there are a couple of options - the excellent magerun tool allows you to customize variables and look at settings on the fly. It doesn’t have the same alias support as drush, but with a little shell magic, you could get it running on remote systems.

Another way to allow access to variables is to create an admin interface for them in the Admin > System > Configuration:

sys config settings




This allows both you and your client to have some control over the application without needing to deploy code. As you develop your application, you can build custom modules to create and tie into variables created in the core_config_data table, and set whatever control specifications you need.

You could even set environment variables that could trigger a host of new settings:

env settings





As you build out your application, you can tie logic in your modules to the configuration variables accessible through the admin.

It’s nice to know there are at least options to allow access and control to the application, while the Magento world waits for its perfect drush.

Read more about: