|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Actualys\Bundle\DrupalCommerceConnectorBundle\Reader\ORM; |
|
4
|
|
|
|
|
5
|
|
|
use Pim\Bundle\BaseConnectorBundle\Reader\Doctrine\ObsoleteProductReader as PimProductReader; |
|
6
|
|
|
use Pim\Bundle\BaseConnectorBundle\Reader\Doctrine\Reader; |
|
7
|
|
|
use Akeneo\Bundle\BatchBundle\Entity\StepExecution; |
|
8
|
|
|
use Pim\Bundle\TransformBundle\Converter\MetricConverter; |
|
9
|
|
|
use Pim\Bundle\CatalogBundle\Manager\ChannelManager; |
|
10
|
|
|
use Pim\Bundle\CatalogBundle\Manager\CompletenessManager; |
|
11
|
|
|
use Pim\Bundle\CatalogBundle\Repository\ProductRepositoryInterface; |
|
12
|
|
|
use Pim\Bundle\CatalogBundle\Model\AbstractProduct; |
|
13
|
|
|
use Actualys\Bundle\DrupalCommerceConnectorBundle\Manager\ProductExportManager; |
|
14
|
|
|
|
|
15
|
|
|
class DeltaProductReader extends PimProductReader |
|
|
|
|
|
|
16
|
|
|
{ |
|
17
|
|
|
protected $productExportManager; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Constructor |
|
21
|
|
|
* |
|
22
|
|
|
* @param ProductRepositoryInterface $repository |
|
23
|
|
|
* @param ChannelManager $channelManager |
|
24
|
|
|
* @param CompletenessManager $completenessManager |
|
25
|
|
|
* @param MetricConverter $metricConverter |
|
26
|
|
|
* @param ProductExportManager $productExportManager |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct( |
|
29
|
|
|
ProductRepositoryInterface $repository, |
|
30
|
|
|
ChannelManager $channelManager, |
|
31
|
|
|
CompletenessManager $completenessManager, |
|
32
|
|
|
MetricConverter $metricConverter, |
|
33
|
|
|
ProductExportManager $productExportManager |
|
34
|
|
|
) { |
|
35
|
|
|
parent::__construct($repository, $channelManager, $completenessManager, $metricConverter); |
|
36
|
|
|
|
|
37
|
|
|
$this->productExportManager = $productExportManager; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* {@inheritdoc} |
|
42
|
|
|
*/ |
|
43
|
|
|
public function read() |
|
44
|
|
|
{ |
|
45
|
|
|
$product = $this->filterProduct(parent::read()); |
|
46
|
|
|
|
|
47
|
|
|
return $product; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Filter products and return only products that got updated since the last export |
|
52
|
|
|
* @param AbstractProduct $readProduct |
|
53
|
|
|
* |
|
54
|
|
|
* @return AbstractProduct|null |
|
55
|
|
|
*/ |
|
56
|
|
|
protected function filterProduct(AbstractProduct $readProduct = null) |
|
57
|
|
|
{ |
|
58
|
|
|
if (null !== $readProduct) { |
|
59
|
|
|
$filteredProduct = $this->productExportManager->filterProduct($readProduct, $this->jobInstance); |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
if ($filteredProduct === null) { |
|
62
|
|
|
return $this->filterProduct(parent::read()); |
|
|
|
|
|
|
63
|
|
|
} else { |
|
64
|
|
|
return $filteredProduct; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return null; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Update the product export date (will be removed later) |
|
73
|
|
|
* @param AbstractProduct $product |
|
74
|
|
|
*/ |
|
75
|
|
|
protected function updateProductExport(AbstractProduct $product) |
|
76
|
|
|
{ |
|
77
|
|
|
$this->productExportManager->updateProductExport($product->getIdentifier(), $this->jobInstance); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* {@inheritdoc} |
|
82
|
|
|
*/ |
|
83
|
|
|
public function setStepExecution(StepExecution $stepExecution) |
|
84
|
|
|
{ |
|
85
|
|
|
parent::setStepExecution($stepExecution); |
|
86
|
|
|
|
|
87
|
|
|
$this->jobInstance = $this->stepExecution->getJobExecution()->getJobInstance(); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.