17
17
use Magento \Catalog \Model \ResourceModel \Product \Indexer \Price \Query \BaseFinalPrice ;
18
18
use Magento \Catalog \Model \ResourceModel \Product \Indexer \Price \IndexTableStructureFactory ;
19
19
use Magento \Catalog \Model \ResourceModel \Product \Indexer \Price \IndexTableStructure ;
20
- use Magento \Store \Model \Indexer \WebsiteDimensionProvider ;
21
- use Magento \Customer \Model \Indexer \CustomerGroupDimensionProvider ;
22
20
23
21
/**
24
22
* Downloadable Product Price Indexer Resource model
@@ -61,11 +59,6 @@ class Price implements DimensionalIndexerInterface
61
59
*/
62
60
private $ connection ;
63
61
64
- /**
65
- * @var string
66
- */
67
- private $ productType ;
68
-
69
62
/**
70
63
* @var Config
71
64
*/
@@ -83,10 +76,8 @@ class Price implements DimensionalIndexerInterface
83
76
* @param MetadataPool $metadataPool
84
77
* @param Config $eavConfig
85
78
* @param ResourceConnection $resource
86
- * @param string $connectionName
87
- * @param string $productType
88
79
* @param BasePriceModifier $basePriceModifier
89
- * @param array $priceModifiers
80
+ * @param string $connectionName
90
81
*/
91
82
public function __construct (
92
83
BaseFinalPrice $ baseFinalPrice ,
@@ -96,13 +87,11 @@ public function __construct(
96
87
Config $ eavConfig ,
97
88
ResourceConnection $ resource ,
98
89
BasePriceModifier $ basePriceModifier ,
99
- $ connectionName = 'indexer ' ,
100
- $ productType = Type::TYPE_DOWNLOADABLE
90
+ $ connectionName = 'indexer '
101
91
) {
102
92
$ this ->baseFinalPrice = $ baseFinalPrice ;
103
93
$ this ->indexTableStructureFactory = $ indexTableStructureFactory ;
104
94
$ this ->tableMaintainer = $ tableMaintainer ;
105
- $ this ->productType = $ productType ;
106
95
$ this ->connectionName = $ connectionName ;
107
96
$ this ->metadataPool = $ metadataPool ;
108
97
$ this ->resource = $ resource ;
@@ -136,6 +125,7 @@ public function executeByDimension(array $dimensions, \Traversable $entityIds =
136
125
137
126
/**
138
127
* Calculate and apply Downloadable links price to index
128
+ *
139
129
* @param IndexTableStructure $temporaryPriceTable
140
130
* @param array $dimensions
141
131
* @return $this
@@ -159,8 +149,10 @@ private function applyDownloadableLink(
159
149
160
150
/**
161
151
* Retrieve catalog_product attribute instance by attribute code
152
+ *
162
153
* @param string $attributeCode
163
154
* @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
155
+ * @throws \Magento\Framework\Exception\LocalizedException
164
156
*/
165
157
protected function getAttribute ($ attributeCode )
166
158
{
@@ -169,6 +161,7 @@ protected function getAttribute($attributeCode)
169
161
170
162
/**
171
163
* Put data into catalog product price indexer Downloadable links price temp table
164
+ *
172
165
* @param string $temporaryDownloadableTableName
173
166
* @param array $dimensions
174
167
* @return void
@@ -211,22 +204,13 @@ private function fillTemporaryTable(string $temporaryDownloadableTableName, arra
211
204
'max_price ' => new \Zend_Db_Expr ('SUM( ' . $ ifPrice . ') ' ),
212
205
]
213
206
);
214
-
215
- foreach ($ dimensions as $ dimension ) {
216
- if ($ dimension ->getName () === WebsiteDimensionProvider::DIMENSION_NAME ) {
217
- $ select ->where ('`i`.website_id = ? ' , $ dimension ->getValue ());
218
- }
219
- if ($ dimension ->getName () === CustomerGroupDimensionProvider::DIMENSION_NAME ) {
220
- $ select ->where ('`i`.customer_group_id = ? ' , $ dimension ->getValue ());
221
- }
222
- }
223
-
224
207
$ query = $ select ->insertFromSelect ($ temporaryDownloadableTableName );
225
208
$ this ->getConnection ()->query ($ query );
226
209
}
227
210
228
211
/**
229
212
* Update data in the catalog product price indexer temp table
213
+ *
230
214
* @param string $temporaryPriceTableName
231
215
* @param string $temporaryDownloadableTableName
232
216
* @return void
@@ -259,6 +243,25 @@ private function updateTemporaryDownloadableTable(
259
243
$ this ->getConnection ()->query ($ query );
260
244
}
261
245
246
+ /**
247
+ * Fill final price
248
+ *
249
+ * @param array $dimensions
250
+ * @param \Traversable $entityIds
251
+ * @param IndexTableStructure $temporaryPriceTable
252
+ * @throws \Magento\Framework\Exception\LocalizedException
253
+ * @throws \Zend_Db_Select_Exception
254
+ */
255
+ private function fillFinalPrice (
256
+ array $ dimensions ,
257
+ \Traversable $ entityIds ,
258
+ IndexTableStructure $ temporaryPriceTable
259
+ ) {
260
+ $ select = $ this ->baseFinalPrice ->getQuery ($ dimensions , Type::TYPE_DOWNLOADABLE , iterator_to_array ($ entityIds ));
261
+ $ query = $ select ->insertFromSelect ($ temporaryPriceTable ->getTableName (), [], false );
262
+ $ this ->tableMaintainer ->getConnection ()->query ($ query );
263
+ }
264
+
262
265
/**
263
266
* Get connection
264
267
*
@@ -270,6 +273,7 @@ private function getConnection(): \Magento\Framework\DB\Adapter\AdapterInterface
270
273
if ($ this ->connection === null ) {
271
274
$ this ->connection = $ this ->resource ->getConnection ($ this ->connectionName );
272
275
}
276
+
273
277
return $ this ->connection ;
274
278
}
275
279
@@ -283,21 +287,4 @@ private function getTable($tableName)
283
287
{
284
288
return $ this ->resource ->getTableName ($ tableName , $ this ->connectionName );
285
289
}
286
-
287
- /**
288
- * @param array $dimensions
289
- * @param \Traversable $entityIds
290
- * @param IndexTableStructure $temporaryPriceTable
291
- * @throws \Magento\Framework\Exception\LocalizedException
292
- * @throws \Zend_Db_Select_Exception
293
- */
294
- private function fillFinalPrice (
295
- array $ dimensions ,
296
- \Traversable $ entityIds ,
297
- IndexTableStructure $ temporaryPriceTable
298
- ) {
299
- $ select = $ this ->baseFinalPrice ->getQuery ($ dimensions , $ this ->productType , iterator_to_array ($ entityIds ));
300
- $ query = $ select ->insertFromSelect ($ temporaryPriceTable ->getTableName (), [], false );
301
- $ this ->tableMaintainer ->getConnection ()->query ($ query );
302
- }
303
290
}
0 commit comments