Github issue related :
https://github.com/magento/magento2/issues/6938
In order to export configurable products with more than 1 variation, you can use this fix. You will be able to export / reimport the csv file.
Remove this when Magento fixed the bug.
di.xml
<preference for="Magento\ConfigurableImportExport\Model\Export\RowCustomizer" type="Vendor\ImportExport\Model\Export\RowCustomizer" />
app/code/Vendor/ImportExport/Model/Export/RowCustomizer.php
<?php
namespace Vendor\ImportExport\Model\Export;
use \Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
use \Magento\ImportExport\Model\Import;
class RowCustomizer extends \Magento\ConfigurableImportExport\Model\Export\RowCustomizer
{
/**
* Prepare configurable data for export
*
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
* @param int[] $productIds
* @return void
*/
public function prepareData($collection, $productIds)
{
$productCollection = clone $collection;
$productCollection->addAttributeToFilter(
'entity_id',
['in' => $productIds]
)->addAttributeToFilter(
'type_id',
['eq' => \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE]
);
while ($product = $productCollection->fetchItem()) {
$productAttributesOptions = $product->getTypeInstance()->getConfigurableOptions($product);
$variations = [];
$variationsLabels = [];
foreach ($productAttributesOptions as $productAttributeOption) {
$this->configurableData[$product->getId()] = [];
foreach ($productAttributeOption as $optValues) {
$variations[$optValues['sku']][] =
$optValues['attribute_code'] . '=' . $optValues['option_title'];
if (!empty($optValues['super_attribute_label'])) {
$variationsLabels[$optValues['attribute_code']] =
$optValues['attribute_code'] . '=' . $optValues['super_attribute_label'];
}
}
}
foreach ($variations as $sku => $values) {
$variations[$sku] =
'sku=' . $sku . Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
. implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $values);
}
$variations = implode(ImportProduct::PSEUDO_MULTI_LINE_SEPARATOR, $variations);
$variationsLabels = implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $variationsLabels);
$this->configurableData[$product->getId()] = [
'configurable_variations' => $variations,
'configurable_variation_labels' => $variationsLabels,
];
}
}
}