Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.3-develop' into MAGETWO-7248…
Browse files Browse the repository at this point in the history
…7-signifyd
  • Loading branch information
Joan He committed Feb 6, 2018
2 parents 52abb74 + 225d00b commit 33b25e6
Show file tree
Hide file tree
Showing 87 changed files with 2,091 additions and 288 deletions.
3 changes: 3 additions & 0 deletions app/code/Magento/Backend/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
<item name="dev" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::HIDDEN</item>
<item name="general/locale/code" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::DISABLED</item>
</argument>
<argument name="exemptions" xsi:type="array">
<item name="dev/debug/debug_logging" xsi:type="string"/>
</argument>
</arguments>
</type>
<type name="Magento\Backend\Model\Search\Config\Result\Builder">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
namespace Magento\Catalog\Test\Unit\Block\Product\View;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class GalleryTest extends \PHPUnit\Framework\TestCase
{
/**
Expand Down
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 33b25e6

Please sign in to comment.