사용자 정의 Magento 쉘 스크립트 - 인수 값을 가져올 수 없습니다
-
29-09-2020 - |
문제
내 media/tmp
디렉토리에서 zip 파일을 추출하는 사용자 지정 쉘 스크립트를 작성하려고 시도합니다.
쉘 디렉토리에 labeler.php 파일을 만들었습니다.Mage_Shell_Abstract
를 확장하고 실행 ()이 다음과 같습니다.
/**
* 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
입니다.내가 얻은 출력은 다음과 같습니다 : unzipping 1
해결책
내가 아는 것에서 내가 올바른 구문이 다음과 같다고 생각하는 것 :
php -f shell/labeler.php -- --unzip file.zip
.
Magento의 쉘 스크립트의 구문은 다음과 같습니다.
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'
제휴하지 않습니다 magento.stackexchange