3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \ConfigurableImportExport \Model \Export ;
7
9
8
- use Magento \CatalogImportExport \Model \Export \RowCustomizerInterface ;
9
10
use Magento \Catalog \Model \ResourceModel \Product \Collection as ProductCollection ;
10
- use Magento \ConfigurableProduct \Model \Product \ Type \ Configurable as ConfigurableProductType ;
11
+ use Magento \CatalogImportExport \Model \Export \ RowCustomizerInterface ;
11
12
use Magento \CatalogImportExport \Model \Import \Product as ImportProduct ;
13
+ use Magento \ConfigurableProduct \Model \Product \Type \Configurable as ConfigurableProductType ;
12
14
use Magento \ImportExport \Model \Import ;
15
+ use Magento \Store \Model \Store ;
16
+ use Magento \Store \Model \StoreManagerInterface ;
13
17
18
+ /**
19
+ * Customizes output during export
20
+ */
14
21
class RowCustomizer implements RowCustomizerInterface
15
22
{
16
23
/**
@@ -36,6 +43,19 @@ class RowCustomizer implements RowCustomizerInterface
36
43
self ::CONFIGURABLE_VARIATIONS_LABELS_COLUMN
37
44
];
38
45
46
+ /**
47
+ * @var StoreManagerInterface
48
+ */
49
+ private $ storeManager ;
50
+
51
+ /**
52
+ * @param StoreManagerInterface $storeManager
53
+ */
54
+ public function __construct (StoreManagerInterface $ storeManager )
55
+ {
56
+ $ this ->storeManager = $ storeManager ;
57
+ }
58
+
39
59
/**
40
60
* Prepare configurable data for export
41
61
*
@@ -49,6 +69,9 @@ public function prepareData($collection, $productIds)
49
69
$ productCollection ->addAttributeToFilter ('entity_id ' , ['in ' => $ productIds ])
50
70
->addAttributeToFilter ('type_id ' , ['eq ' => ConfigurableProductType::TYPE_CODE ]);
51
71
72
+ // set global scope during export
73
+ $ this ->storeManager ->setCurrentStore (Store::DEFAULT_STORE_ID );
74
+
52
75
while ($ product = $ productCollection ->fetchItem ()) {
53
76
$ productAttributesOptions = $ product ->getTypeInstance ()->getConfigurableOptions ($ product );
54
77
$ this ->configurableData [$ product ->getId ()] = [];
0 commit comments