Skip to content

Commit a98fdd2

Browse files
committed
MAGETWO-96381: Configurable Product based on Swatch with different Admin & Front labels exported with wrong labels
- Set correct scope for products export
1 parent 733f2fc commit a98fdd2

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\ConfigurableImportExport\Model\Export;
79

8-
use Magento\CatalogImportExport\Model\Export\RowCustomizerInterface;
910
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;
1112
use Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
13+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableProductType;
1214
use Magento\ImportExport\Model\Import;
15+
use Magento\Store\Model\Store;
16+
use Magento\Store\Model\StoreManagerInterface;
1317

18+
/**
19+
* Customizes output during export
20+
*/
1421
class RowCustomizer implements RowCustomizerInterface
1522
{
1623
/**
@@ -36,6 +43,19 @@ class RowCustomizer implements RowCustomizerInterface
3643
self::CONFIGURABLE_VARIATIONS_LABELS_COLUMN
3744
];
3845

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+
3959
/**
4060
* Prepare configurable data for export
4161
*
@@ -49,6 +69,9 @@ public function prepareData($collection, $productIds)
4969
$productCollection->addAttributeToFilter('entity_id', ['in' => $productIds])
5070
->addAttributeToFilter('type_id', ['eq' => ConfigurableProductType::TYPE_CODE]);
5171

72+
// set global scope during export
73+
$this->storeManager->setCurrentStore(Store::DEFAULT_STORE_ID);
74+
5275
while ($product = $productCollection->fetchItem()) {
5376
$productAttributesOptions = $product->getTypeInstance()->getConfigurableOptions($product);
5477
$this->configurableData[$product->getId()] = [];

app/code/Magento/ConfigurableImportExport/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"magento/module-catalog-import-export": "*",
1212
"magento/module-configurable-product": "*",
1313
"magento/module-eav": "*",
14-
"magento/module-import-export": "*"
14+
"magento/module-import-export": "*",
15+
"magento/module-store": "*"
1516
},
1617
"type": "magento2-module",
1718
"license": [

0 commit comments

Comments
 (0)