Skip to content

Commit 64298b3

Browse files
Merge branch '2.2-develop' of github.com:magento/magento2ce into SPRINT-41
2 parents 3532719 + 4d9d6b0 commit 64298b3

File tree

26 files changed

+628
-140
lines changed

26 files changed

+628
-140
lines changed

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function getDefaultValues()
142142
*/
143143
protected function _getSelectedOptions()
144144
{
145-
if (is_null($this->_selectedOptions)) {
145+
if ($this->_selectedOptions === null) {
146146
$this->_selectedOptions = [];
147147

148148
/** @var \Magento\Bundle\Model\Option $option */
@@ -152,17 +152,29 @@ protected function _getSelectedOptions()
152152
$selectionId = $this->getProduct()->getPreconfiguredValues()->getData(
153153
'bundle_option/' . $option->getId()
154154
);
155-
if ($selectionId && $option->getSelectionById($selectionId)) {
156-
$this->_selectedOptions = $selectionId;
157-
} elseif (!$option->getRequired()) {
158-
$this->_selectedOptions = 'None';
159-
}
155+
$this->assignSelection($option, $selectionId);
160156
}
161157
}
162158

163159
return $this->_selectedOptions;
164160
}
165161

162+
/**
163+
* Set selected options.
164+
*
165+
* @param \Magento\Bundle\Model\Option $option
166+
* @param mixed $selectionId
167+
* @return void
168+
*/
169+
protected function assignSelection(\Magento\Bundle\Model\Option $option, $selectionId)
170+
{
171+
if ($selectionId && $option->getSelectionById($selectionId)) {
172+
$this->_selectedOptions = $selectionId;
173+
} elseif (!$option->getRequired()) {
174+
$this->_selectedOptions = 'None';
175+
}
176+
}
177+
166178
/**
167179
* Define if selection is selected
168180
*

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Multi.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,20 @@ class Multi extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Optio
1717
* @var string
1818
*/
1919
protected $_template = 'catalog/product/view/type/bundle/option/multi.phtml';
20+
21+
/**
22+
* @inheritdoc
23+
*/
24+
protected function assignSelection(\Magento\Bundle\Model\Option $option, $selectionId)
25+
{
26+
if (is_array($selectionId)) {
27+
foreach ($selectionId as $id) {
28+
if ($id && $option->getSelectionById($id)) {
29+
$this->_selectedOptions[] = $id;
30+
}
31+
}
32+
} else {
33+
parent::assignSelection($option, $selectionId);
34+
}
35+
}
2036
}

app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/options.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
<?php
1212
$product = $block->getProduct();
1313
$helper = $this->helper('Magento\Catalog\Helper\Output');
14+
$stripSelection = $product->getConfigureMode() ? true : false;
15+
$options = $block->decorateArray($block->getOptions($stripSelection));
1416
?>
15-
<?php $options = $block->decorateArray($block->getOptions()); ?>
1617
<?php if ($product->isSaleable()):?>
1718
<?php if (count($options)): ?>
1819
<script type="text/x-magento-init">

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

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
153153
/**
154154
* Items per page for collection limitation
155155
*
156-
* @var null
156+
* @var int|null
157157
*/
158158
protected $_itemsPerPage = null;
159159

160160
/**
161161
* Header columns for export file
162162
*
163163
* @var array
164+
* @deprecated
164165
*/
165166
protected $_headerColumns = [];
166167

@@ -234,17 +235,15 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
234235
protected $_fieldsMap = [
235236
'image' => 'base_image',
236237
'image_label' => "base_image_label",
237-
'image' => 'base_image',
238-
'image_label' => 'base_image_label',
239238
'thumbnail' => 'thumbnail_image',
240239
'thumbnail_label' => 'thumbnail_image_label',
241240
self::COL_MEDIA_IMAGE => 'additional_images',
242241
'_media_image_label' => 'additional_image_labels',
243-
Product::COL_STORE => 'store_view_code',
244-
Product::COL_ATTR_SET => 'attribute_set_code',
245-
Product::COL_TYPE => 'product_type',
246-
Product::COL_CATEGORY => 'categories',
247-
Product::COL_PRODUCT_WEBSITES => 'product_websites',
242+
self::COL_STORE => 'store_view_code',
243+
self::COL_ATTR_SET => 'attribute_set_code',
244+
self::COL_TYPE => 'product_type',
245+
self::COL_CATEGORY => 'categories',
246+
self::COL_PRODUCT_WEBSITES => 'product_websites',
248247
'status' => 'product_online',
249248
'news_from_date' => 'new_from_date',
250249
'news_to_date' => 'new_to_date',
@@ -691,7 +690,7 @@ protected function updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $pr
691690
*/
692691
public function _getHeaderColumns()
693692
{
694-
return $this->_customHeadersMapping($this->_headerColumns);
693+
return $this->_customHeadersMapping($this->rowCustomizer->addHeaderColumns($this->_headerColumns));
695694
}
696695

697696
/**
@@ -700,13 +699,13 @@ public function _getHeaderColumns()
700699
* @param array $customOptionsData
701700
* @param array $stockItemRows
702701
* @return void
702+
* @deprecated Logic will be moved to _getHeaderColumns in future release
703+
*
704+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
703705
*/
704706
protected function setHeaderColumns($customOptionsData, $stockItemRows)
705707
{
706708
if (!$this->_headerColumns) {
707-
$customOptCols = [
708-
'custom_options',
709-
];
710709
$this->_headerColumns = array_merge(
711710
[
712711
self::COL_SKU,
@@ -719,21 +718,19 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows)
719718
$this->_getExportMainAttrCodes(),
720719
[self::COL_ADDITIONAL_ATTRIBUTES],
721720
reset($stockItemRows) ? array_keys(end($stockItemRows)) : [],
722-
[],
723721
[
724722
'related_skus',
725723
'related_position',
726724
'crosssell_skus',
727725
'crosssell_position',
728726
'upsell_skus',
729-
'upsell_position'
730-
],
731-
['additional_images', 'additional_image_labels', 'hide_from_product_page']
727+
'upsell_position',
728+
'additional_images',
729+
'additional_image_labels',
730+
'hide_from_product_page',
731+
'custom_options'
732+
]
732733
);
733-
// have we merge custom options columns
734-
if ($customOptionsData) {
735-
$this->_headerColumns = array_merge($this->_headerColumns, $customOptCols);
736-
}
737734
}
738735
}
739736

@@ -892,10 +889,12 @@ protected function getExportData()
892889
$productIds = array_keys($rawData);
893890
$stockItemRows = $this->prepareCatalogInventory($productIds);
894891

895-
$this->rowCustomizer->prepareData($this->_getEntityCollection(), $productIds);
892+
$this->rowCustomizer->prepareData(
893+
$this->_prepareEntityCollection($this->_entityCollectionFactory->create()),
894+
$productIds
895+
);
896896

897897
$this->setHeaderColumns($multirawData['customOptionsData'], $stockItemRows);
898-
$this->_headerColumns = $this->rowCustomizer->addHeaderColumns($this->_headerColumns);
899898

900899
foreach ($rawData as $productId => $productData) {
901900
foreach ($productData as $storeId => $dataRow) {
@@ -1231,9 +1230,6 @@ private function appendMultirowData(&$dataRow, &$multiRawData)
12311230
return null;
12321231
} elseif ($storeId != Store::DEFAULT_STORE_ID) {
12331232
$dataRow[self::COL_STORE] = $this->_storeIdToCode[$storeId];
1234-
if (isset($productData[Store::DEFAULT_STORE_ID][self::COL_VISIBILITY])) {
1235-
$dataRow[self::COL_VISIBILITY] = $productData[Store::DEFAULT_STORE_ID][self::COL_VISIBILITY];
1236-
}
12371233
}
12381234
$dataRow[self::COL_SKU] = $sku;
12391235
return $dataRow;

app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,15 @@ public function testGetHeaderColumns()
270270
$headerColumnsValue = ['headerColumns value'];
271271
$expectedResult = 'result';
272272
$this->setPropertyValue($product, '_headerColumns', $headerColumnsValue);
273-
$product
274-
->expects($this->once())
273+
$this->setPropertyValue($product, 'rowCustomizer', $this->rowCustomizer);
274+
$product->expects($this->once())
275275
->method('_customHeadersMapping')
276276
->with($headerColumnsValue)
277277
->willReturn($expectedResult);
278+
$this->rowCustomizer->expects($this->once())
279+
->method('addHeaderColumns')
280+
->with($headerColumnsValue)
281+
->willReturn($headerColumnsValue);
278282

279283
$result = $product->_getHeaderColumns();
280284

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

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,29 @@
1313

1414
class RowCustomizer implements RowCustomizerInterface
1515
{
16+
/**
17+
* Header column for Configurable Product variations
18+
*/
19+
const CONFIGURABLE_VARIATIONS_COLUMN = 'configurable_variations';
20+
21+
/**
22+
* Header column for Configurable Product variation labels
23+
*/
24+
const CONFIGURABLE_VARIATIONS_LABELS_COLUMN = 'configurable_variation_labels';
25+
1626
/**
1727
* @var array
1828
*/
1929
protected $configurableData = [];
2030

31+
/**
32+
* @var string[]
33+
*/
34+
private $configurableColumns = [
35+
self::CONFIGURABLE_VARIATIONS_COLUMN,
36+
self::CONFIGURABLE_VARIATIONS_LABELS_COLUMN
37+
];
38+
2139
/**
2240
* Prepare configurable data for export
2341
*
@@ -54,8 +72,11 @@ public function prepareData($collection, $productIds)
5472
}
5573

5674
$this->configurableData[$product->getId()] = [
57-
'configurable_variations' => implode(ImportProduct::PSEUDO_MULTI_LINE_SEPARATOR, $variations),
58-
'configurable_variation_labels' => implode(
75+
self::CONFIGURABLE_VARIATIONS_COLUMN => implode(
76+
ImportProduct::PSEUDO_MULTI_LINE_SEPARATOR,
77+
$variations
78+
),
79+
self::CONFIGURABLE_VARIATIONS_LABELS_COLUMN => implode(
5980
Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
6081
$variationsLabels
6182
)
@@ -71,17 +92,7 @@ public function prepareData($collection, $productIds)
7192
*/
7293
public function addHeaderColumns($columns)
7394
{
74-
// have we merge configurable products data
75-
if (!empty($this->configurableData)) {
76-
$columns = array_merge(
77-
$columns,
78-
[
79-
'configurable_variations',
80-
'configurable_variation_labels',
81-
]
82-
);
83-
}
84-
return $columns;
95+
return array_merge($columns, $this->configurableColumns);
8596
}
8697

8798
/**

app/code/Magento/Directory/Setup/InstallData.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -809,27 +809,6 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
809809
['BR', 'SE', 'Sergipe'],
810810
['BR', 'TO', 'Tocantins'],
811811
['BR', 'DF', 'Distrito Federal'],
812-
['HR', 'HR-01', 'Zagrebačka županija'],
813-
['HR', 'HR-02', 'Krapinsko-zagorska županija'],
814-
['HR', 'HR-03', 'Sisačko-moslavačka županija'],
815-
['HR', 'HR-04', 'Karlovačka županija'],
816-
['HR', 'HR-05', 'Varaždinska županija'],
817-
['HR', 'HR-06', 'Koprivničko-križevačka županija'],
818-
['HR', 'HR-07', 'Bjelovarsko-bilogorska županija'],
819-
['HR', 'HR-08', 'Primorsko-goranska županija'],
820-
['HR', 'HR-09', 'Ličko-senjska županija'],
821-
['HR', 'HR-10', 'Virovitičko-podravska županija'],
822-
['HR', 'HR-11', 'Požeško-slavonska županija'],
823-
['HR', 'HR-12', 'Brodsko-posavska županija'],
824-
['HR', 'HR-13', 'Zadarska županija'],
825-
['HR', 'HR-14', 'Osječko-baranjska županija'],
826-
['HR', 'HR-15', 'Šibensko-kninska županija'],
827-
['HR', 'HR-16', 'Vukovarsko-srijemska županija'],
828-
['HR', 'HR-17', 'Splitsko-dalmatinska županija'],
829-
['HR', 'HR-18', 'Istarska županija'],
830-
['HR', 'HR-19', 'Dubrovačko-neretvanska županija'],
831-
['HR', 'HR-20', 'Međimurska županija'],
832-
['HR', 'HR-21', 'Grad Zagreb']
833812
];
834813

835814
foreach ($data as $row) {

0 commit comments

Comments
 (0)