in the process of creating a custom module to learn the magento structure but I am stuck in how to handle errors. Well maybe the way I created my module is already off but it works for now. Only want to add some error feedback. So let me explain.
With this tutorial I created my module.
https://www.atwix.com/magento/add-button-to-system-configuration/
So in my adminhtml I have an ajax button calling my controller function check
<script type="text/javascript">
//<![CDATA[
function check() {
new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
method: 'get',
onSuccess: function(transport){
if (transport.responseText){
alert('Checked')
}
}
});
}
//]]>
</script>
<?php echo $this->getButtonHtml() ?>
In my controller file I am calling multiple helper files
public function checkAction()
{
Mage::helper('Module/Copy')->copy();
Mage::helper('Module/Changexml')->changexml();
Example helper file
class Module_module_Helper_Copy extends Mage_Core_Helper_Abstract
{
public function copy()
{
$source = Mage::getBaseDir();
$dest = Mage::getStoreConfig('Module/module/folder');
shell_exec("cp -r $source $dest");
}
What I now want to add is if something goes wrong in my helper function I actually show that message in the admin through the button.phtml file (first code). The code I added is just an example and in the original tutorial the function was like this
public function checkAction()
{
$result = 1;
Mage::app()->getResponse()->setBody($result);
is it even ok to call multiple helper file after each other from an observer file? Sorry for the questions, eager to learn how this should be done.!