@@ -352,7 +352,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
352
352
* @param \Magento\Framework\App\ResourceConnection $resource
353
353
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
354
354
* @param \Psr\Log\LoggerInterface $logger
355
- * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
355
+ * @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory
356
356
* @param \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig
357
357
* @param \Magento\Catalog\Model\ResourceModel\ProductFactory $productFactory
358
358
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $attrSetColFactory
@@ -361,9 +361,10 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
361
361
* @param \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory $optionColFactory
362
362
* @param \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeColFactory
363
363
* @param Product\Type\Factory $_typeFactory
364
- * @param \Magento\Catalog\Model\Product \LinkTypeProvider $linkTypeProvider
365
- * @param \Magento\CatalogImportExport\Model\Export\ RowCustomizerInterface $rowCustomizer
364
+ * @param ProductEntity \LinkTypeProvider $linkTypeProvider
365
+ * @param RowCustomizerInterface $rowCustomizer
366
366
* @param array $dateAttrCodes
367
+ * @throws \Magento\Framework\Exception\LocalizedException
367
368
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
368
369
*/
369
370
public function __construct (
@@ -517,10 +518,13 @@ protected function getMediaGallery(array $productIds)
517
518
if (empty ($ productIds )) {
518
519
return [];
519
520
}
521
+
522
+ $ productEntityJoinField = $ this ->getProductEntityLinkField ();
523
+
520
524
$ select = $ this ->_connection ->select ()->from (
521
525
['mgvte ' => $ this ->_resourceModel ->getTableName ('catalog_product_entity_media_gallery_value_to_entity ' )],
522
526
[
523
- "mgvte. { $ this -> getProductEntityLinkField ()} " ,
527
+ "mgvte. $ productEntityJoinField " ,
524
528
'mgvte.value_id '
525
529
]
526
530
)->joinLeft (
@@ -532,22 +536,22 @@ protected function getMediaGallery(array $productIds)
532
536
]
533
537
)->joinLeft (
534
538
['mgv ' => $ this ->_resourceModel ->getTableName ('catalog_product_entity_media_gallery_value ' )],
535
- ' (mg.value_id = mgv.value_id) ' ,
539
+ " (mg.value_id = mgv.value_id) and (mgvte. $ productEntityJoinField = mgv. $ productEntityJoinField ) " ,
536
540
[
537
541
'mgv.label ' ,
538
542
'mgv.position ' ,
539
543
'mgv.disabled ' ,
540
544
'mgv.store_id '
541
545
]
542
546
)->where (
543
- "mgvte. { $ this -> getProductEntityLinkField ()} IN (?) " ,
547
+ "mgvte. $ productEntityJoinField IN (?) " ,
544
548
$ productIds
545
549
);
546
550
547
551
$ rowMediaGallery = [];
548
552
$ stmt = $ this ->_connection ->query ($ select );
549
553
while ($ mediaRow = $ stmt ->fetch ()) {
550
- $ rowMediaGallery [$ mediaRow [$ this -> getProductEntityLinkField () ]][] = [
554
+ $ rowMediaGallery [$ mediaRow [$ productEntityJoinField ]][] = [
551
555
'_media_attribute_id ' => $ mediaRow ['attribute_id ' ],
552
556
'_media_image ' => $ mediaRow ['filename ' ],
553
557
'_media_label ' => $ mediaRow ['label ' ],
@@ -689,6 +693,8 @@ protected function updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $pr
689
693
}
690
694
691
695
/**
696
+ * Get header columns
697
+ *
692
698
* {@inheritdoc}
693
699
*/
694
700
public function _getHeaderColumns ()
@@ -748,6 +754,8 @@ protected function _getExportMainAttrCodes()
748
754
}
749
755
750
756
/**
757
+ * Get entity collection
758
+ *
751
759
* {@inheritdoc}
752
760
*/
753
761
protected function _getEntityCollection ($ resetCollection = false )
@@ -818,9 +826,8 @@ protected function paginateCollection($page, $pageSize)
818
826
}
819
827
820
828
/**
821
- * Export process
822
- *
823
829
* @return string
830
+ * @throws \Magento\Framework\Exception\LocalizedException
824
831
*/
825
832
public function export ()
826
833
{
@@ -854,7 +861,11 @@ public function export()
854
861
}
855
862
856
863
/**
857
- * {@inheritdoc}
864
+ * Apply filter to collection and add not skipped attributes to select.
865
+ *
866
+ * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
867
+ * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
868
+ *
858
869
* @since 100.2.0
859
870
*/
860
871
protected function _prepareEntityCollection (\Magento \Eav \Model \Entity \Collection \AbstractCollection $ collection )
@@ -916,11 +927,10 @@ protected function getExportData()
916
927
}
917
928
918
929
/**
919
- * Load products' data from the collection
920
- * and filter it (if needed).
930
+ * Load products' data from the collection and filter it (if needed).
921
931
*
922
- * @return array Keys are product IDs, values arrays with keys as store IDs
923
- * and values as store-specific versions of Product entity.
932
+ * @return array Keys are product IDs, values arrays with keys as store ID
933
+ * and values as store-specific versions of Product entity.
924
934
*/
925
935
protected function loadCollection (): array
926
936
{
0 commit comments