1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Actualys\Bundle\DrupalCommerceConnectorBundle\Writer; |
4
|
|
|
|
5
|
|
|
use Akeneo\Bundle\BatchBundle\Entity\JobInstance; |
6
|
|
|
use Pim\Bundle\CatalogBundle\Manager\ChannelManager; |
7
|
|
|
use Pim\Bundle\DeltaExportBundle\Manager\ProductExportManager; |
8
|
|
|
use Akeneo\Bundle\BatchBundle\Entity\StepExecution; |
9
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher; |
10
|
|
|
use Guzzle\Http\Exception\ClientErrorResponseException; |
11
|
|
|
|
12
|
|
|
class DeltaProductWriter extends ProductWriter |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var ProductExportManager |
16
|
|
|
*/ |
17
|
|
|
protected $productExportManager; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var JobInstance |
21
|
|
|
*/ |
22
|
|
|
protected $jobInstance; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var EventDispatcher |
26
|
|
|
*/ |
27
|
|
|
protected $eventDispatcher; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Constructor |
31
|
|
|
* |
32
|
|
|
* @param EventDispatcher $eventDispatcher |
33
|
|
|
* @param ChannelManager $channelManager |
34
|
|
|
* @param ProductExportManager $productExportManager |
35
|
|
|
*/ |
36
|
|
|
public function __construct( |
37
|
|
|
EventDispatcher $eventDispatcher, |
38
|
|
|
ChannelManager $channelManager, |
|
|
|
|
39
|
|
|
ProductExportManager $productExportManager |
40
|
|
|
) { |
41
|
|
|
$this->eventDispatcher = $eventDispatcher; |
42
|
|
|
$this->productExportManager = $productExportManager; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param array $items |
47
|
|
|
*/ |
48
|
|
|
public function write(array $items) |
49
|
|
|
{ |
50
|
|
|
parent::write($items); |
51
|
|
|
foreach ($items as $item) { |
52
|
|
|
$this->productExportManager->updateProductExport( |
53
|
|
|
$item['sku'], |
54
|
|
|
$this->jobInstance |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
|
|
public function setStepExecution(StepExecution $stepExecution) |
63
|
|
|
{ |
64
|
|
|
parent::setStepExecution($stepExecution); |
65
|
|
|
|
66
|
|
|
$this->jobInstance = $stepExecution->getJobExecution()->getJobInstance( |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.