I can execute a shell script from a custom php script. I have no trouble including the abstract.php, log a string or calling let's say the product model. Playing around with including parameters from the php script to the shell script is no problem either.

But when it comes to calling a custom helper-function like this:


and var_dump() the result (or whatever function you like) I get nothing. I've called the helper function a dozen times in other scripts. It seems that the helper function cannot be executed in a shell script. Whatever helper method for that matter. I tried to call other helpers too.

Is my deduction a valid one or do I miss the knowledge of execution a shell script? In other words: is it possible to execute a custom helper function in a shell script?


thanks in advance for all your replies!

here's my code


require_once 'abstract.php';

class Santee_Shell_Upload extends Mage_Shell_Abstract {

    public function run() {
        global $argv;
        $path = $argv[1];

        $dir = Mage::getBaseDir() . "/shell/";
        $objects = MAGE::helper('updateproducts/runupdate')->getAllObjects($path);

        $command = 'php -f ' . $dir . 'indexer.php reindexall';
        $result = shell_exec($command);

    public function usageHelp() {
        return <<<USAGE
Usage:  php -f upload.php -- [options]
        php -f upload.php 



$shell = new Santee_Shell_Upload();
  • Could you post your code? There's no reason why a helper wouldn't work in a script that I can think of.
    – Laura
    Feb 24, 2015 at 20:31
  • Calling a helper method from the shell is perfectly possible, depending on how Magento is bootstrapped you may get unexpected results. For example some functions will return different information from a frontend store than from the admin store, which is what most scripts are bootstrapped as. Feb 24, 2015 at 20:43
  • Could you post your config file as well as your helper function? Also, you are calling all of your helpers with MAGE in all caps. Are you on a windows server? Casing matters in windows. Feb 25, 2015 at 16:23

1 Answer 1


The answer is yes. You have the full availability of Magento's abstract factory when you run a shell script. My guess is there is a problem with your helper declaration or your module's config file.

What is the scope of your declaration of your helpers? Is it in the <global> node?

  • Hi Ryan, yes the helpers are declared as global Feb 25, 2015 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.