20
20
* @SuppressWarnings(PHPMD.TooManyFields)
21
21
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
22
22
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
23
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
23
24
* @since 100.0.2
24
25
*/
25
26
class Product extends \Magento \ImportExport \Model \Export \Entity \AbstractEntity
@@ -349,12 +350,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
349
350
private $ productEntityLinkField ;
350
351
351
352
/**
353
+ * Product constructor.
352
354
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
353
355
* @param \Magento\Eav\Model\Config $config
354
356
* @param \Magento\Framework\App\ResourceConnection $resource
355
357
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
356
358
* @param \Psr\Log\LoggerInterface $logger
357
- * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
359
+ * @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory
358
360
* @param \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig
359
361
* @param \Magento\Catalog\Model\ResourceModel\ProductFactory $productFactory
360
362
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $attrSetColFactory
@@ -363,10 +365,10 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
363
365
* @param \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory $optionColFactory
364
366
* @param \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeColFactory
365
367
* @param Product\Type\Factory $_typeFactory
366
- * @param \Magento\Catalog\Model\Product \LinkTypeProvider $linkTypeProvider
367
- * @param \Magento\CatalogImportExport\Model\Export\ RowCustomizerInterface $rowCustomizer
368
+ * @param ProductEntity \LinkTypeProvider $linkTypeProvider
369
+ * @param RowCustomizerInterface $rowCustomizer
368
370
* @param array $dateAttrCodes
369
- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
371
+ * @throws \Magento\Framework\Exception\LocalizedException
370
372
*/
371
373
public function __construct (
372
374
\Magento \Framework \Stdlib \DateTime \TimezoneInterface $ localeDate ,
@@ -520,10 +522,13 @@ protected function getMediaGallery(array $productIds)
520
522
if (empty ($ productIds )) {
521
523
return [];
522
524
}
525
+
526
+ $ productEntityJoinField = $ this ->getProductEntityLinkField ();
527
+
523
528
$ select = $ this ->_connection ->select ()->from (
524
529
['mgvte ' => $ this ->_resourceModel ->getTableName ('catalog_product_entity_media_gallery_value_to_entity ' )],
525
530
[
526
- "mgvte. { $ this -> getProductEntityLinkField ()} " ,
531
+ "mgvte. $ productEntityJoinField " ,
527
532
'mgvte.value_id '
528
533
]
529
534
)->joinLeft (
@@ -535,22 +540,22 @@ protected function getMediaGallery(array $productIds)
535
540
]
536
541
)->joinLeft (
537
542
['mgv ' => $ this ->_resourceModel ->getTableName ('catalog_product_entity_media_gallery_value ' )],
538
- ' (mg.value_id = mgv.value_id) ' ,
543
+ " (mg.value_id = mgv.value_id) and (mgvte. $ productEntityJoinField = mgv. $ productEntityJoinField ) " ,
539
544
[
540
545
'mgv.label ' ,
541
546
'mgv.position ' ,
542
547
'mgv.disabled ' ,
543
548
'mgv.store_id ' ,
544
549
]
545
550
)->where (
546
- "mgvte. { $ this -> getProductEntityLinkField ()} IN (?) " ,
551
+ "mgvte. $ productEntityJoinField IN (?) " ,
547
552
$ productIds
548
553
);
549
554
550
555
$ rowMediaGallery = [];
551
556
$ stmt = $ this ->_connection ->query ($ select );
552
557
while ($ mediaRow = $ stmt ->fetch ()) {
553
- $ rowMediaGallery [$ mediaRow [$ this -> getProductEntityLinkField () ]][] = [
558
+ $ rowMediaGallery [$ mediaRow [$ productEntityJoinField ]][] = [
554
559
'_media_attribute_id ' => $ mediaRow ['attribute_id ' ],
555
560
'_media_image ' => $ mediaRow ['filename ' ],
556
561
'_media_label ' => $ mediaRow ['label ' ],
@@ -692,7 +697,9 @@ protected function updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $pr
692
697
}
693
698
694
699
/**
695
- * {@inheritdoc}
700
+ * Get header columns
701
+ *
702
+ * @return string[]
696
703
*/
697
704
public function _getHeaderColumns ()
698
705
{
@@ -751,7 +758,10 @@ protected function _getExportMainAttrCodes()
751
758
}
752
759
753
760
/**
754
- * {@inheritdoc}
761
+ * Get entity collection
762
+ *
763
+ * @param bool $resetCollection
764
+ * @return \Magento\Framework\Data\Collection\AbstractDb
755
765
*/
756
766
protected function _getEntityCollection ($ resetCollection = false )
757
767
{
@@ -858,7 +868,10 @@ public function export()
858
868
}
859
869
860
870
/**
861
- * {@inheritdoc}
871
+ * Apply filter to collection and add not skipped attributes to select.
872
+ *
873
+ * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
874
+ * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
862
875
* @since 100.2.0
863
876
*/
864
877
protected function _prepareEntityCollection (\Magento \Eav \Model \Entity \Collection \AbstractCollection $ collection )
@@ -920,8 +933,7 @@ protected function getExportData()
920
933
}
921
934
922
935
/**
923
- * Load products' data from the collection
924
- * and filter it (if needed).
936
+ * Load products' data from the collection and filter it (if needed).
925
937
*
926
938
* @return array Keys are product IDs, values arrays with keys as store IDs
927
939
* and values as store-specific versions of Product entity.
@@ -1063,6 +1075,8 @@ private function wrapValue($value)
1063
1075
}
1064
1076
1065
1077
/**
1078
+ * Collect multi raw data from
1079
+ *
1066
1080
* @return array
1067
1081
*/
1068
1082
protected function collectMultirawData ()
@@ -1104,6 +1118,8 @@ protected function collectMultirawData()
1104
1118
}
1105
1119
1106
1120
/**
1121
+ * Check the current data has multiselect value
1122
+ *
1107
1123
* @param \Magento\Catalog\Model\Product $item
1108
1124
* @param int $storeId
1109
1125
* @return bool
@@ -1116,6 +1132,8 @@ protected function hasMultiselectData($item, $storeId)
1116
1132
}
1117
1133
1118
1134
/**
1135
+ * Collect multiselect values based on value
1136
+ *
1119
1137
* @param \Magento\Catalog\Model\Product $item
1120
1138
* @param string $attrCode
1121
1139
* @param int $storeId
@@ -1140,6 +1158,8 @@ protected function collectMultiselectValues($item, $attrCode, $storeId)
1140
1158
}
1141
1159
1142
1160
/**
1161
+ * Check attribute is valid
1162
+ *
1143
1163
* @param string $code
1144
1164
* @param mixed $value
1145
1165
* @return bool
@@ -1159,6 +1179,8 @@ protected function isValidAttributeValue($code, $value)
1159
1179
}
1160
1180
1161
1181
/**
1182
+ * Append multi row data
1183
+ *
1162
1184
* @param array $dataRow
1163
1185
* @param array $multiRawData
1164
1186
* @return array
@@ -1288,6 +1310,8 @@ private function appendMultirowData(&$dataRow, $multiRawData)
1288
1310
}
1289
1311
1290
1312
/**
1313
+ * Add multi row data to export
1314
+ *
1291
1315
* @deprecated 100.1.0
1292
1316
* @param array $dataRow
1293
1317
* @param array $multiRawData
@@ -1335,6 +1359,8 @@ protected function _customHeadersMapping($rowData)
1335
1359
}
1336
1360
1337
1361
/**
1362
+ * Convert option row to cell string
1363
+ *
1338
1364
* @param array $option
1339
1365
* @return string
1340
1366
*/
0 commit comments