Skip to content

Commit 3e1f5a4

Browse files
author
Korshenko, Olexii(okorshenko)
committed
Merge pull request #63 from magento-nord/develop
[Nord] GA Bug fixes
2 parents ec5598b + 1a584f8 commit 3e1f5a4

File tree

47 files changed

+2186
-740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2186
-740
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\CatalogImportExport\Model\Import\Product as ImportProductModel;
1111
use Magento\Bundle\Model\ResourceModel\Selection\Collection as SelectionCollection;
1212
use Magento\ImportExport\Controller\Adminhtml\Import;
13+
use Magento\ImportExport\Model\Import as ImportModel;
1314

1415
/**
1516
* Class RowCustomizer
@@ -90,20 +91,21 @@ class RowCustomizer implements RowCustomizerInterface
9091
* Prepare data for export
9192
*
9293
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
93-
* @param int $productIds
94+
* @param int[] $productIds
9495
* @return $this
9596
*/
9697
public function prepareData($collection, $productIds)
9798
{
98-
$collection->addAttributeToFilter(
99+
$productCollection = clone $collection;
100+
$productCollection->addAttributeToFilter(
99101
'entity_id',
100102
['in' => $productIds]
101103
)->addAttributeToFilter(
102104
'type_id',
103105
['eq' => \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE]
104106
);
105107

106-
return $this->populateBundleData($collection);
108+
return $this->populateBundleData($productCollection);
107109
}
108110

109111
/**
@@ -214,9 +216,9 @@ protected function getFormattedBundleSelections($optionValues, SelectionCollecti
214216
'price_type' => $this->getPriceTypeValue($selection->getSelectionPriceType())
215217
];
216218
$bundleData .= $optionValues
217-
. ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
219+
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
218220
. implode(
219-
ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
221+
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
220222
array_map(
221223
function ($value, $key) {
222224
return $key . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $value;
@@ -240,9 +242,9 @@ function ($value, $key) {
240242
protected function getFormattedOptionValues($option)
241243
{
242244
return 'name' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
243-
. $option->getTitle() . ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
245+
. $option->getTitle() . ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
244246
. 'type' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
245-
. $option->getType() . ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
247+
. $option->getType() . ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
246248
. 'required' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
247249
. $option->getRequired();
248250
}
@@ -290,7 +292,7 @@ protected function cleanNotBundleAdditionalAttributes($dataRow)
290292
{
291293
if (!empty($dataRow['additional_attributes'])) {
292294
$additionalAttributes = explode(
293-
ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
295+
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
294296
$dataRow['additional_attributes']
295297
);
296298
$dataRow['additional_attributes'] = $this->getNotBundleAttributes($additionalAttributes);
@@ -314,10 +316,10 @@ protected function getNotBundleAttributes($additionalAttributes)
314316
$cleanedAdditionalAttributes .= $attributeCode
315317
. ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
316318
. $attributeValue
317-
. ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
319+
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
318320
}
319321
}
320322

321-
return rtrim($cleanedAdditionalAttributes, ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
323+
return rtrim($cleanedAdditionalAttributes, ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
322324
}
323325
}

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\CatalogImportExport\Model\Export;
77

8+
use Magento\ImportExport\Model\Import;
89
use \Magento\Store\Model\Store;
910
use \Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
1011

@@ -638,7 +639,7 @@ protected function updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $pr
638639
}
639640
$categories[] = $categoryPath;
640641
}
641-
$dataRow[self::COL_CATEGORY] = implode(ImportProduct::PSEUDO_MULTI_LINE_SEPARATOR, $categories);
642+
$dataRow[self::COL_CATEGORY] = implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $categories);
642643
unset($rowCategories[$productId]);
643644

644645
return true;
@@ -672,7 +673,7 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows)
672673
self::COL_ATTR_SET,
673674
self::COL_TYPE,
674675
self::COL_CATEGORY,
675-
'_product_websites',
676+
self::COL_PRODUCT_WEBSITES,
676677
],
677678
$this->_getExportMainAttrCodes(),
678679
[self::COL_ADDITIONAL_ATTRIBUTES],
@@ -683,7 +684,7 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows)
683684
'crosssell_skus',
684685
'upsell_skus',
685686
],
686-
['additional_images', 'additional_image_labels']
687+
['additional_images', 'additional_image_labels', 'hide_from_product_page']
687688
);
688689
// have we merge custom options columns
689690
if ($customOptionsData) {
@@ -901,7 +902,7 @@ protected function collectRawData()
901902

902903
if (!empty($additionalAttributes)) {
903904
$data[$itemId][$storeId][self::COL_ADDITIONAL_ATTRIBUTES] =
904-
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalAttributes);
905+
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalAttributes);
905906
} else {
906907
unset($data[$itemId][$storeId][self::COL_ADDITIONAL_ATTRIBUTES]);
907908
}
@@ -981,7 +982,7 @@ protected function hasMultiselectData($item, $storeId)
981982
protected function collectMultiselectValues($item, $attrCode, $storeId)
982983
{
983984
$attrValue = $item->getData($attrCode);
984-
$optionIds = explode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $attrValue);
985+
$optionIds = explode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $attrValue);
985986
$options = array_intersect_key(
986987
$this->_attributeValues[$attrCode],
987988
array_flip($optionIds)
@@ -1040,21 +1041,28 @@ protected function addMultirowData($dataRow, $multiRawData)
10401041
foreach ($multiRawData['rowWebsites'][$productId] as $productWebsite) {
10411042
$websiteCodes[] = $this->_websiteIdToCode[$productWebsite];
10421043
}
1043-
$dataRow['_product_websites'] =
1044-
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $websiteCodes);
1044+
$dataRow[self::COL_PRODUCT_WEBSITES] =
1045+
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $websiteCodes);
10451046
$multiRawData['rowWebsites'][$productId] = [];
10461047
}
10471048
if (!empty($multiRawData['mediaGalery'][$productId])) {
10481049
$additionalImages = [];
10491050
$additionalImageLabels = [];
1051+
$additionalImageIsDisabled = [];
10501052
foreach ($multiRawData['mediaGalery'][$productId] as $mediaItem) {
10511053
$additionalImages[] = $mediaItem['_media_image'];
10521054
$additionalImageLabels[] = $mediaItem['_media_label'];
1055+
1056+
if ($mediaItem['_media_is_disabled'] == true) {
1057+
$additionalImageIsDisabled[] = $mediaItem['_media_image'];
1058+
}
10531059
}
10541060
$dataRow['additional_images'] =
1055-
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImages);
1061+
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImages);
10561062
$dataRow['additional_image_labels'] =
1057-
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImageLabels);
1063+
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImageLabels);
1064+
$dataRow['hide_from_product_page'] =
1065+
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImageIsDisabled);
10581066
$multiRawData['mediaGalery'][$productId] = [];
10591067
}
10601068
foreach ($this->_linkTypeProvider->getLinkTypes() as $linkTypeName => $linkId) {
@@ -1074,7 +1082,7 @@ protected function addMultirowData($dataRow, $multiRawData)
10741082
$multiRawData['linksRows'][$productId][$linkId] = [];
10751083
asort($associations);
10761084
$dataRow[$colPrefix . 'skus'] =
1077-
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, array_keys($associations));
1085+
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, array_keys($associations));
10781086
}
10791087
}
10801088
$dataRow = $this->rowCustomizer->addData($dataRow, $productId);
@@ -1085,7 +1093,7 @@ protected function addMultirowData($dataRow, $multiRawData)
10851093
foreach (array_keys($this->collectedMultiselectsData[$storeId][$productId]) as $attrKey) {
10861094
if (!empty($this->collectedMultiselectsData[$storeId][$productId][$attrKey])) {
10871095
$dataRow[$attrKey] = implode(
1088-
ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
1096+
Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
10891097
$this->collectedMultiselectsData[$storeId][$productId][$attrKey]
10901098
);
10911099
}
@@ -1161,7 +1169,7 @@ protected function optionRowToCellString($option)
11611169
$result[] = $key . ImportProduct::PAIR_NAME_VALUE_SEPARATOR . $value;
11621170
}
11631171

1164-
return implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $result);
1172+
return implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $result);
11651173
}
11661174

11671175
/**

app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer/Composite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(ObjectManagerInterface $objectManager, $customizers
3434
* Prepare data for export
3535
*
3636
* @param mixed $collection
37-
* @param int $productIds
37+
* @param int[] $productIds
3838
* @return mixed|void
3939
*/
4040
public function prepareData($collection, $productIds)

app/code/Magento/CatalogImportExport/Model/Export/RowCustomizerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface RowCustomizerInterface
1414
* Prepare data for export
1515
*
1616
* @param mixed $collection
17-
* @param int $productIds
17+
* @param int[] $productIds
1818
* @return mixed
1919
*/
2020
public function prepareData($collection, $productIds);

0 commit comments

Comments
 (0)