Skip to content

Commit

Permalink
magento#17784 [CatalogImportExport][export] - added website store vie…
Browse files Browse the repository at this point in the history
…ws to exported CSV
  • Loading branch information
Yupik committed Sep 11, 2018
1 parent 7474def commit 102b0b4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/code/Magento/CatalogImportExport/Model/Export/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\CatalogImportExport\Model\Export;

use Magento\ImportExport\Model\Import;
Expand Down Expand Up @@ -123,6 +124,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
*/
protected $_websiteIdToCode = [];

/**
* Website store views
*
* @var array
*/
private $_websiteStoreViews = [];

/**
* Attribute types
*
Expand Down Expand Up @@ -502,6 +510,10 @@ protected function initWebsites()
/** @var $website \Magento\Store\Model\Website */
foreach ($this->_storeManager->getWebsites() as $website) {
$this->_websiteIdToCode[$website->getId()] = $website->getCode();
foreach ($website->getStores() as $store) {
/** @var \Magento\Store\Model\Store $store */
$this->_websiteStoreViews[$website->getId()][$store->getId()] = $store->getCode();
}
}
return $this;
}
Expand Down Expand Up @@ -1183,11 +1195,20 @@ private function appendMultirowData(&$dataRow, $multiRawData)
$this->updateDataWithCategoryColumns($dataRow, $multiRawData['rowCategories'], $productId);
if (!empty($multiRawData['rowWebsites'][$productId])) {
$websiteCodes = [];
$websiteStoreViewCodes = [];
foreach ($multiRawData['rowWebsites'][$productId] as $productWebsite) {
$websiteCodes[] = $this->_websiteIdToCode[$productWebsite];
if (isset($this->_websiteStoreViews[$productWebsite])) {
$websiteStoreViewCodes = array_merge(
$websiteStoreViewCodes,
$this->_websiteStoreViews[$productWebsite]
);
}
}
$dataRow[self::COL_PRODUCT_WEBSITES] =
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $websiteCodes);
$dataRow[self::COL_STORE] =
implode(IMPORT::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $websiteStoreViewCodes);
$multiRawData['rowWebsites'][$productId] = [];
}
if (!empty($multiRawData['mediaGalery'][$productLinkId])) {
Expand Down

0 comments on commit 102b0b4

Please sign in to comment.