Skip to content

8255: Export Products action doesn't consider hide_for_product_page value. #11926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
12cb7fc
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 1, 2017
d6b1d3e
Merge branch '2.2-develop' into 8255
nmalevanec Nov 1, 2017
b7703ac
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 1, 2017
426183c
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 2, 2017
3fabf2c
Merge branch '2.2-develop' into 8255
nmalevanec Nov 13, 2017
f891450
Merge branch '2.2-develop' into 8255
nmalevanec Nov 13, 2017
64ddd51
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 14, 2017
a159dae
Merge branch '2.2-develop' into 8255
nmalevanec Nov 14, 2017
2a1b041
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 14, 2017
da8184f
Merge branch '2.2-develop' into 8255
nmalevanec Nov 22, 2017
cbd8b28
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 23, 2017
51fa4bc
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 23, 2017
5dc5acd
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 24, 2017
334ef2f
Merge branch '2.2-develop' into 8255
nmalevanec Nov 24, 2017
8aa3da1
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 27, 2017
9f6e51d
Merge branch '2.2-develop' into 8255
nmalevanec Nov 27, 2017
a22d223
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 28, 2017
e46c8fd
8255: Export Products action doesn't consider hide_for_product_page v…
nmalevanec Nov 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions app/code/Magento/CatalogImportExport/Model/Export/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,12 @@ protected function getMediaGallery(array $productIds)
]
)->joinLeft(
['mgv' => $this->_resourceModel->getTableName('catalog_product_entity_media_gallery_value')],
'(mg.value_id = mgv.value_id AND mgv.store_id = 0)',
'(mg.value_id = mgv.value_id)',
[
'mgv.label',
'mgv.position',
'mgv.disabled'
'mgv.disabled',
'mgv.store_id'
]
)->where(
"mgvte.{$this->getProductEntityLinkField()} IN (?)",
Expand All @@ -552,6 +553,7 @@ protected function getMediaGallery(array $productIds)
'_media_label' => $mediaRow['label'],
'_media_position' => $mediaRow['position'],
'_media_is_disabled' => $mediaRow['disabled'],
'_media_store_id' => $mediaRow['store_id'],
];
}

Expand Down Expand Up @@ -931,8 +933,8 @@ protected function loadCollection(): array
foreach ($collection as $itemId => $item) {
$data[$itemId][$storeId] = $item;
}
$collection->clear();
}
$collection->clear();

return $data;
}
Expand Down Expand Up @@ -1024,12 +1026,10 @@ protected function collectRawData()
unset($data[$itemId][$storeId][self::COL_ADDITIONAL_ATTRIBUTES]);
}

if (!empty($data[$itemId][$storeId]) || $this->hasMultiselectData($item, $storeId)) {
$attrSetId = $item->getAttributeSetId();
$data[$itemId][$storeId][self::COL_STORE] = $storeCode;
$data[$itemId][$storeId][self::COL_ATTR_SET] = $this->_attrSetIdToName[$attrSetId];
$data[$itemId][$storeId][self::COL_TYPE] = $item->getTypeId();
}
$attrSetId = $item->getAttributeSetId();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also change the behavior for non-image multi-select data also? Do we have a test covering this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It covers by Magento/CatalogImportExport/Model/Export/ProductTest::testExport() for instance. Exported product has multiselect data.

$data[$itemId][$storeId][self::COL_STORE] = $storeCode;
$data[$itemId][$storeId][self::COL_ATTR_SET] = $this->_attrSetIdToName[$attrSetId];
$data[$itemId][$storeId][self::COL_TYPE] = $item->getTypeId();
$data[$itemId][$storeId][self::COL_SKU] = htmlspecialchars_decode($item->getSku());
$data[$itemId][$storeId]['store_id'] = $storeId;
$data[$itemId][$storeId]['product_id'] = $itemId;
Expand Down Expand Up @@ -1104,6 +1104,7 @@ protected function collectMultirawData()
* @param \Magento\Catalog\Model\Product $item
* @param int $storeId
* @return bool
* @deprecated
*/
protected function hasMultiselectData($item, $storeId)
{
Expand Down Expand Up @@ -1162,20 +1163,23 @@ protected function isValidAttributeValue($code, $value)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
private function appendMultirowData(&$dataRow, &$multiRawData)
private function appendMultirowData(&$dataRow, $multiRawData)
{
$productId = $dataRow['product_id'];
$productLinkId = $dataRow['product_link_id'];
$storeId = $dataRow['store_id'];
$sku = $dataRow[self::COL_SKU];
$type = $dataRow[self::COL_TYPE];
$attributeSet = $dataRow[self::COL_ATTR_SET];

unset($dataRow['product_id']);
unset($dataRow['product_link_id']);
unset($dataRow['store_id']);
unset($dataRow[self::COL_SKU]);

unset($dataRow[self::COL_STORE]);
unset($dataRow[self::COL_ATTR_SET]);
unset($dataRow[self::COL_TYPE]);
if (Store::DEFAULT_STORE_ID == $storeId) {
unset($dataRow[self::COL_STORE]);
$this->updateDataWithCategoryColumns($dataRow, $multiRawData['rowCategories'], $productId);
if (!empty($multiRawData['rowWebsites'][$productId])) {
$websiteCodes = [];
Expand All @@ -1191,11 +1195,13 @@ private function appendMultirowData(&$dataRow, &$multiRawData)
$additionalImageLabels = [];
$additionalImageIsDisabled = [];
foreach ($multiRawData['mediaGalery'][$productLinkId] as $mediaItem) {
$additionalImages[] = $mediaItem['_media_image'];
$additionalImageLabels[] = $mediaItem['_media_label'];
if ((int)$mediaItem['_media_store_id'] === Store::DEFAULT_STORE_ID) {
$additionalImages[] = $mediaItem['_media_image'];
$additionalImageLabels[] = $mediaItem['_media_label'];

if ($mediaItem['_media_is_disabled'] == true) {
$additionalImageIsDisabled[] = $mediaItem['_media_image'];
if ($mediaItem['_media_is_disabled'] == true) {
$additionalImageIsDisabled[] = $mediaItem['_media_image'];
}
}
}
$dataRow['additional_images'] =
Expand Down Expand Up @@ -1229,6 +1235,21 @@ private function appendMultirowData(&$dataRow, &$multiRawData)
}
}
$dataRow = $this->rowCustomizer->addData($dataRow, $productId);
} else {
$additionalImageIsDisabled = [];
if (!empty($multiRawData['mediaGalery'][$productLinkId])) {
foreach ($multiRawData['mediaGalery'][$productLinkId] as $mediaItem) {
if ((int)$mediaItem['_media_store_id'] === $storeId) {
if ($mediaItem['_media_is_disabled'] == true) {
$additionalImageIsDisabled[] = $mediaItem['_media_image'];
}
}
}
}
if ($additionalImageIsDisabled) {
$dataRow['hide_from_product_page'] =
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImageIsDisabled);
}
}

if (!empty($this->collectedMultiselectsData[$storeId][$productId])) {
Expand Down Expand Up @@ -1256,6 +1277,9 @@ private function appendMultirowData(&$dataRow, &$multiRawData)
$dataRow[self::COL_STORE] = $this->_storeIdToCode[$storeId];
}
$dataRow[self::COL_SKU] = $sku;
$dataRow[self::COL_ATTR_SET] = $attributeSet;
$dataRow[self::COL_TYPE] = $type;

return $dataRow;
}

Expand Down
Loading