This code will allow you to add a function that can be called from anywhere within Magento. It extends the helper class
1) Create a file named ‘Mycode.xml’ and copy it to app/etc/modules/ – it should look like this:
version="1.0"?> true local
2) Create the directory
app/code/local/Mycode/Function/etc
and then create a file named ‘config.xml’
In it copy:
version="1.0"?> 1.0.0 Mycode_Function_Helper
3) Create the directory
app/code/local/Mycode/Function/Helper
and then create a file named ‘Data.php’
In it copy:
class Mycode_Function_Helper_Data extends Mage_Core_Helper_Abstract { public function test(){ return 'works'; } }
You can now call this function like so
echo Mage::helper('function')->test(); ?>
No comments:
Post a Comment