forked from ripenecommerce/magento2-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPATCH_MDVA-4538_EE_2.1.4_v2_part2.composer.patch
executable file
·151 lines (136 loc) · 4.11 KB
/
PATCH_MDVA-4538_EE_2.1.4_v2_part2.composer.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
diff --git a/Indexer/Action/Base.php b/Indexer/Action/Base.php
index e7edcae..d761f38 100644
--- a/Indexer/Action/Base.php
+++ b/Indexer/Action/Base.php
@@ -37,11 +37,13 @@ class Base implements ActionInterface
/**
* @var AdapterInterface
+ * @deprecated
*/
protected $connection;
/**
* @var SourceProviderInterface[]
+ * @deprecated
*/
protected $sources;
@@ -52,6 +54,7 @@ class Base implements ActionInterface
/**
* @var HandlerInterface[]
+ * @deprecated
*/
protected $handlers;
@@ -62,6 +65,7 @@ class Base implements ActionInterface
/**
* @var array
+ * @deprecated
*/
protected $columnTypesMap = [
'varchar' => ['type' => Table::TYPE_TEXT, 'size' => 255],
@@ -71,11 +75,13 @@ class Base implements ActionInterface
/**
* @var array
+ * @deprecated
*/
protected $filterColumns;
/**
* @var array
+ * @deprecated
*/
protected $searchColumns;
@@ -96,6 +102,7 @@ class Base implements ActionInterface
/**
* @var String
+ * @deprecated
*/
protected $string;
@@ -106,11 +113,13 @@ class Base implements ActionInterface
/**
* @var array
+ * @deprecated
*/
protected $filterable = [];
/**
* @var array
+ * @deprecated
*/
protected $searchable = [];
@@ -272,6 +281,7 @@ class Base implements ActionInterface
protected function createResultCollection()
{
$select = $this->getPrimaryResource()->getSelect();
+ $select->reset(\Magento\Framework\DB\Select::COLUMNS);
$select->columns($this->getPrimaryResource()->getIdFieldName());
foreach ($this->data['fieldsets'] as $fieldset) {
if (isset($fieldset['references'])) {
@@ -342,6 +352,8 @@ class Base implements ActionInterface
*
* @param array $field
* @return void
+ *
+ * @deprecated
*/
protected function saveFieldByType($field)
{
diff --git a/Indexer/Action/Entity.php b/Indexer/Action/Entity.php
index e88d281..b8390b9 100644
--- a/Indexer/Action/Entity.php
+++ b/Indexer/Action/Entity.php
@@ -24,6 +24,6 @@ class Entity extends Base
{
return !count($ids)
? $this->createResultCollection()
- : $this->createResultCollection()->addFieldToFilter($this->getPrimaryResource()->getRowIdFieldName(), $ids);
+ : $this->createResultCollection()->addFieldToFilter($this->getPrimaryResource()->getIdFieldName(), $ids);
}
}
diff --git a/Indexer/SaveHandler/Batch.php b/Indexer/SaveHandler/Batch.php
index 31883fa..7d53e55 100644
--- a/Indexer/SaveHandler/Batch.php
+++ b/Indexer/SaveHandler/Batch.php
@@ -10,27 +10,23 @@ class Batch
/**
* @param \Traversable $documents
* @param int $size
- * @return array
+ * @return \Generator
*/
public function getItems(\Traversable $documents, $size)
{
- if (count($documents) == 0) {
- return [];
- }
-
$i = 0;
- $batch = $items = [];
+ $batch = [];
+
foreach ($documents as $documentName => $documentValue) {
$batch[$documentName] = $documentValue;
- if (++$i >= $size) {
- $items[] = $batch;
+ if (++$i == $size) {
+ yield $batch;
$i = 0;
$batch = [];
}
}
if (count($batch) > 0) {
- $items[] = $batch;
+ yield $batch;
}
- return $items;
}
}
diff --git a/Indexer/Test/Unit/BatchTest.php b/Indexer/Test/Unit/BatchTest.php
index 0df9812..1571bba 100644
--- a/Indexer/Test/Unit/BatchTest.php
+++ b/Indexer/Test/Unit/BatchTest.php
@@ -27,7 +27,8 @@ class BatchTest extends \PHPUnit_Framework_TestCase
public function testGetItems(array $itemsData, $size, array $expected)
{
$items = new \ArrayObject($itemsData);
- $this->assertSame($expected, $this->object->getItems($items, $size));
+ $data = $this->object->getItems($items, $size);
+ $this->assertSame($expected, iterator_to_array($data));
}
/**