2020 * @SuppressWarnings(PHPMD.TooManyFields)
2121 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2222 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
23+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
2324 * @since 100.0.2
2425 */
2526class Product extends \Magento \ImportExport \Model \Export \Entity \AbstractEntity
@@ -349,12 +350,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
349350 private $ productEntityLinkField ;
350351
351352 /**
353+ * Product constructor.
352354 * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
353355 * @param \Magento\Eav\Model\Config $config
354356 * @param \Magento\Framework\App\ResourceConnection $resource
355357 * @param \Magento\Store\Model\StoreManagerInterface $storeManager
356358 * @param \Psr\Log\LoggerInterface $logger
357- * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
359+ * @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory
358360 * @param \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig
359361 * @param \Magento\Catalog\Model\ResourceModel\ProductFactory $productFactory
360362 * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $attrSetColFactory
@@ -363,10 +365,10 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
363365 * @param \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory $optionColFactory
364366 * @param \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeColFactory
365367 * @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
368370 * @param array $dateAttrCodes
369- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
371+ * @throws \Magento\Framework\Exception\LocalizedException
370372 */
371373 public function __construct (
372374 \Magento \Framework \Stdlib \DateTime \TimezoneInterface $ localeDate ,
@@ -520,10 +522,13 @@ protected function getMediaGallery(array $productIds)
520522 if (empty ($ productIds )) {
521523 return [];
522524 }
525+
526+ $ productEntityJoinField = $ this ->getProductEntityLinkField ();
527+
523528 $ select = $ this ->_connection ->select ()->from (
524529 ['mgvte ' => $ this ->_resourceModel ->getTableName ('catalog_product_entity_media_gallery_value_to_entity ' )],
525530 [
526- "mgvte. { $ this -> getProductEntityLinkField ()} " ,
531+ "mgvte. $ productEntityJoinField " ,
527532 'mgvte.value_id '
528533 ]
529534 )->joinLeft (
@@ -535,22 +540,22 @@ protected function getMediaGallery(array $productIds)
535540 ]
536541 )->joinLeft (
537542 ['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 ) " ,
539544 [
540545 'mgv.label ' ,
541546 'mgv.position ' ,
542547 'mgv.disabled ' ,
543548 'mgv.store_id ' ,
544549 ]
545550 )->where (
546- "mgvte. { $ this -> getProductEntityLinkField ()} IN (?) " ,
551+ "mgvte. $ productEntityJoinField IN (?) " ,
547552 $ productIds
548553 );
549554
550555 $ rowMediaGallery = [];
551556 $ stmt = $ this ->_connection ->query ($ select );
552557 while ($ mediaRow = $ stmt ->fetch ()) {
553- $ rowMediaGallery [$ mediaRow [$ this -> getProductEntityLinkField () ]][] = [
558+ $ rowMediaGallery [$ mediaRow [$ productEntityJoinField ]][] = [
554559 '_media_attribute_id ' => $ mediaRow ['attribute_id ' ],
555560 '_media_image ' => $ mediaRow ['filename ' ],
556561 '_media_label ' => $ mediaRow ['label ' ],
@@ -692,7 +697,9 @@ protected function updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $pr
692697 }
693698
694699 /**
695- * {@inheritdoc}
700+ * Get header columns
701+ *
702+ * @return string[]
696703 */
697704 public function _getHeaderColumns ()
698705 {
@@ -751,7 +758,10 @@ protected function _getExportMainAttrCodes()
751758 }
752759
753760 /**
754- * {@inheritdoc}
761+ * Get entity collection
762+ *
763+ * @param bool $resetCollection
764+ * @return \Magento\Framework\Data\Collection\AbstractDb
755765 */
756766 protected function _getEntityCollection ($ resetCollection = false )
757767 {
@@ -858,7 +868,10 @@ public function export()
858868 }
859869
860870 /**
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
862875 * @since 100.2.0
863876 */
864877 protected function _prepareEntityCollection (\Magento \Eav \Model \Entity \Collection \AbstractCollection $ collection )
@@ -920,8 +933,7 @@ protected function getExportData()
920933 }
921934
922935 /**
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).
925937 *
926938 * @return array Keys are product IDs, values arrays with keys as store IDs
927939 * and values as store-specific versions of Product entity.
@@ -1063,6 +1075,8 @@ private function wrapValue($value)
10631075 }
10641076
10651077 /**
1078+ * Collect multi raw data from
1079+ *
10661080 * @return array
10671081 */
10681082 protected function collectMultirawData ()
@@ -1104,6 +1118,8 @@ protected function collectMultirawData()
11041118 }
11051119
11061120 /**
1121+ * Check the current data has multiselect value
1122+ *
11071123 * @param \Magento\Catalog\Model\Product $item
11081124 * @param int $storeId
11091125 * @return bool
@@ -1116,6 +1132,8 @@ protected function hasMultiselectData($item, $storeId)
11161132 }
11171133
11181134 /**
1135+ * Collect multiselect values based on value
1136+ *
11191137 * @param \Magento\Catalog\Model\Product $item
11201138 * @param string $attrCode
11211139 * @param int $storeId
@@ -1140,6 +1158,8 @@ protected function collectMultiselectValues($item, $attrCode, $storeId)
11401158 }
11411159
11421160 /**
1161+ * Check attribute is valid
1162+ *
11431163 * @param string $code
11441164 * @param mixed $value
11451165 * @return bool
@@ -1159,6 +1179,8 @@ protected function isValidAttributeValue($code, $value)
11591179 }
11601180
11611181 /**
1182+ * Append multi row data
1183+ *
11621184 * @param array $dataRow
11631185 * @param array $multiRawData
11641186 * @return array
@@ -1288,6 +1310,8 @@ private function appendMultirowData(&$dataRow, $multiRawData)
12881310 }
12891311
12901312 /**
1313+ * Add multi row data to export
1314+ *
12911315 * @deprecated 100.1.0
12921316 * @param array $dataRow
12931317 * @param array $multiRawData
@@ -1335,6 +1359,8 @@ protected function _customHeadersMapping($rowData)
13351359 }
13361360
13371361 /**
1362+ * Convert option row to cell string
1363+ *
13381364 * @param array $option
13391365 * @return string
13401366 */
0 commit comments