Helps are useful to prevent duplicated code (in models, templates, ...) and sometime they are just necessary.
- for checking if you custom module is enabled, you can place something like
Mage::getStoreConfigFlag('my/module/enabled')
to every file where you want to check this, or you useMage::helper('my_module')->isEnabled()
with benefits: - if ie the config path changes for some reason, you just have to adjust one file
- you can rewrite helpers
isEnabled()
method and it will affect all classes that use it, instead of rewriting several files - 13th @ How to write a custom extension?: Do not rewrite classes unless is necessary. Use observers and if it's not possible to use helper methods that receive as parameter and instance of a class that you wanted to override. Wrong: Override
Mage_Catalog_Model_Product
to add the methodgetProductArticles()
. Right. In your helper addgetProductArticles(Mage_Catalog_Model_Product $product)
- make layout updates more flexible using
<action method="someMethod"><var helper="module/method" /></action>
You can just create a helper called
Data.php
in each module and leave it empty.
When using PHPUnit you should add one single line: protected $_moduleName = 'My_Module';