我正在尝试创建一个自定义shell脚本,该脚本将在我的 media/tmp 目录。

我创造了一个贴标机。shell目录下的php文件。它延伸 Mage_Shell_Abstract 和run()看起来像这样:

/**
 * Run script
 *
 */
public function run()
{
    $_SESSION = array();
    if ($this->getArg('unzip')) {
        $zipFile = strval($this->getArg('unzip'));
        echo "Unzipping {$zipFile}";
    }elseif ($this->getArg('pendingList')) {
        echo "this\n";
    } else {
        echo $this->usageHelp();
    }
}

我正在执行的命令是 php -f shell/labeler.php -- unzip file.zip.我得到的输出是: 拆装1

有帮助吗?

解决方案

从我所知道的我认为正确的语法如下:

php -f shell/labeler.php -- --unzip file.zip

Magento中shell脚本的语法是 :

php -f script.php -- [options]

选项可能只是一个像这样的标志:

php -f script.php -- test

那样的话 $this->getArg('test') 将返回1(true)。

或者它可能是这样的值:

php -f script.php -- --test mytest

那样的话 $this->getArg('test') 将返回'mytest'

许可以下: CC-BY-SA归因
scroll top