1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of gpupo/netshoes-sdk |
5
|
|
|
* Created by Gilmar Pupo <[email protected]> |
6
|
|
|
* For the information of copyright and license you should read the file |
7
|
|
|
* LICENSE which is distributed with this source code. |
8
|
|
|
* Para a informação dos direitos autorais e de licença você deve ler o arquivo |
9
|
|
|
* LICENSE que é distribuído com este código-fonte. |
10
|
|
|
* Para obtener la información de los derechos de autor y la licencia debe leer |
11
|
|
|
* el archivo LICENSE que se distribuye con el código fuente. |
12
|
|
|
* For more information, see <https://www.gpupo.com/>. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Gpupo\NetshoesSdk\Console\Command; |
16
|
|
|
|
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @codeCoverageIgnore |
22
|
|
|
*/ |
23
|
|
|
final class DetailCommand extends AbstractCommand |
24
|
|
|
{ |
25
|
|
|
public function main($app) |
26
|
|
|
{ |
27
|
|
|
$opts = [ |
28
|
|
|
['key' => 'file'], |
29
|
|
|
[ |
30
|
|
|
'key' => 'type', |
31
|
|
|
'options' => ['Price', 'PriceSchedule', 'Stock', 'Status'], |
32
|
|
|
'default' => 'Price', |
33
|
|
|
], |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
$this->getApp()->appendCommand('product:sku:detail:update', 'Atualiza detalhes de um SKU', $opts) |
37
|
|
|
->setCode(function (InputInterface $input, OutputInterface $output) use ($app, $opts) { |
38
|
|
|
$list = $app->processInputParameters($opts, $input, $output); |
39
|
|
|
|
40
|
|
|
$data = $app->jsonLoadFromFile($list['file']); |
41
|
|
|
$sdk = $app->factorySdk($list); |
42
|
|
|
$sku = $sdk->createSku($data); |
43
|
|
|
|
44
|
|
|
try { |
45
|
|
|
$type = ucfirst($list['type']); |
46
|
|
|
$operation = $sdk->factoryManager('sku')->saveDetail($sku, $type); |
47
|
|
|
|
48
|
|
|
if (in_array($operation->getHttpStatusCode(), [200, 201], true)) { |
49
|
|
|
$output->writeln('Atualizando <comment>'.$type.'</comment>'); |
50
|
|
|
$output->writeln('<info>Successo!</info>'); |
51
|
|
|
} |
52
|
|
|
} catch (\Exception $e) { |
53
|
|
|
$app->showException($e, $output); |
54
|
|
|
} |
55
|
|
|
}); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|