|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\GiftCard; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
6
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
8
|
|
|
use N98\Util\Console\Helper\Table\Renderer\RendererFactory; |
|
9
|
|
|
use Magento\GiftCardAccount\Model\Giftcardaccount; |
|
10
|
|
|
|
|
11
|
|
|
class InfoCommand extends AbstractGiftCardCommand |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Setup |
|
15
|
|
|
* |
|
16
|
|
|
* @return void |
|
17
|
|
|
*/ |
|
18
|
|
|
protected function configure() |
|
19
|
|
|
{ |
|
20
|
|
|
$this |
|
21
|
|
|
->setName('giftcard:info') |
|
22
|
|
|
->addArgument('code', \Symfony\Component\Console\Input\InputArgument::REQUIRED, 'Gift card code') |
|
23
|
|
|
->addOption( |
|
24
|
|
|
'format', |
|
25
|
|
|
null, |
|
26
|
|
|
InputOption::VALUE_OPTIONAL, |
|
27
|
|
|
'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' |
|
28
|
|
|
) |
|
29
|
|
|
->setDescription('Get gift card account information by code'); |
|
30
|
|
|
|
|
31
|
|
|
$help = <<<HELP |
|
32
|
|
|
Get gift card account information by code |
|
33
|
|
|
HELP; |
|
34
|
|
|
$this->setHelp($help); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
|
39
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
|
40
|
|
|
* @return void |
|
41
|
|
|
*/ |
|
42
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->detectMagento($output, true); |
|
45
|
|
|
if (!$this->initMagento()) { |
|
46
|
|
|
return; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$this->setAdminArea(); |
|
50
|
|
|
|
|
51
|
|
|
$card = $this->getGiftcard($input->getArgument('code')); |
|
52
|
|
|
if (!$card->getId()) { |
|
53
|
|
|
$output->writeln('<error>No gift card found for that code</error>'); |
|
54
|
|
|
return; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$data = array( |
|
58
|
|
|
array('Gift Card Account ID', $card->getId()), |
|
59
|
|
|
array('Code', $card->getCode()), |
|
60
|
|
|
array('Status', Giftcardaccount::STATUS_ENABLED == $card->getStatus() ? 'Enabled' : 'Disabled'), |
|
61
|
|
|
array('Date Created', $card->getDateCreated()), |
|
62
|
|
|
array('Expiration Date', $card->getDateExpires()), |
|
63
|
|
|
array('Website ID', $card->getWebsiteId()), |
|
64
|
|
|
array('Remaining Balance', $card->getBalance()), |
|
65
|
|
|
array('State', $card->getStateText()), |
|
66
|
|
|
array('Is Redeemable', $card->getIsRedeemable()) |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
$this->getHelper('table') |
|
70
|
|
|
->setHeaders(array('Name', 'Value')) |
|
71
|
|
|
->setRows($data) |
|
72
|
|
|
->renderByFormat($output, $data, $input->getOption('format')); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|