Skip to content

Commit

Permalink
Merge forwardport of #11926 to 2.3-develop branch
Browse files Browse the repository at this point in the history
Applied pull request patch https://github.com/magento/magento2/pull/11926.patch (created by @nmalevanec) based on commit(s):
  1. 12cb7fc
  2. d6b1d3e
  3. b7703ac
  4. 426183c
  5. 3fabf2c
  6. f891450
  7. 64ddd51
  8. a159dae
  9. 2a1b041
  10. da8184f
  11. cbd8b28
  12. 51fa4bc
  13. 5dc5acd
  14. 334ef2f
  15. 8aa3da1
  16. 9f6e51d
  17. a22d223
  18. e46c8fd

Fixed GitHub Issues in 2.3-develop branch:
  - #8255: Export Products action doesn't consider hide_for_product_page value (reported by @barbanet)
  • Loading branch information
magento-engcom-team authored Feb 5, 2018
2 parents ad317c2 + 2653b8a commit 53e721c
Show file tree
Hide file tree
Showing 9 changed files with 537 additions and 181 deletions.
53 changes: 39 additions & 14 deletions app/code/Magento/CatalogImportExport/Model/Export/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,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 @@ -553,6 +554,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 @@ -1001,12 +1003,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();
$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 @@ -1082,6 +1082,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 @@ -1140,20 +1141,24 @@ 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 @@ -1169,11 +1174,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 @@ -1207,6 +1214,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 @@ -1234,6 +1256,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

0 comments on commit 53e721c

Please sign in to comment.