Skip to content

Commit 32e5b0b

Browse files
author
Stanislav Idolov
committed
Merge remote-tracking branch 'mainline/develop' into bugs
2 parents 26d7e9e + 353ef4f commit 32e5b0b

File tree

28 files changed

+869
-63
lines changed

28 files changed

+869
-63
lines changed

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

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,7 @@ private function getShipmentTypeValue($type)
331331
protected function cleanNotBundleAdditionalAttributes($dataRow)
332332
{
333333
if (!empty($dataRow['additional_attributes'])) {
334-
$additionalAttributes = explode(
335-
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
336-
$dataRow['additional_attributes']
337-
);
334+
$additionalAttributes = $this->parseAdditionalAttributes($dataRow['additional_attributes']);
338335
$dataRow['additional_attributes'] = $this->getNotBundleAttributes($additionalAttributes);
339336
}
340337

@@ -349,17 +346,38 @@ protected function cleanNotBundleAdditionalAttributes($dataRow)
349346
*/
350347
protected function getNotBundleAttributes($additionalAttributes)
351348
{
352-
$cleanedAdditionalAttributes = '';
353-
foreach ($additionalAttributes as $attribute) {
354-
list($attributeCode, $attributeValue) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attribute);
355-
if (!in_array('bundle_' . $attributeCode, $this->getBundleColumns())) {
356-
$cleanedAdditionalAttributes .= $attributeCode
357-
. ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
358-
. $attributeValue
359-
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
349+
$filteredAttributes = [];
350+
foreach ($additionalAttributes as $code => $value) {
351+
if (!in_array('bundle_' . $code, $this->getBundleColumns())) {
352+
$filteredAttributes[] = $code . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $value;
360353
}
361354
}
355+
return implode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $filteredAttributes);
356+
}
362357

363-
return rtrim($cleanedAdditionalAttributes, ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
358+
/**
359+
* Retrieves additional attributes as array code=>value.
360+
*
361+
* @param string $additionalAttributes
362+
* @return array
363+
*/
364+
private function parseAdditionalAttributes($additionalAttributes)
365+
{
366+
$attributeNameValuePairs = explode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalAttributes);
367+
$preparedAttributes = [];
368+
$code = '';
369+
foreach ($attributeNameValuePairs as $attributeData) {
370+
//process case when attribute has ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR inside its value
371+
if (strpos($attributeData, ImportProductModel::PAIR_NAME_VALUE_SEPARATOR) === false) {
372+
if (!$code) {
373+
continue;
374+
}
375+
$preparedAttributes[$code] .= ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR . $attributeData;
376+
continue;
377+
}
378+
list($code, $value) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attributeData, 2);
379+
$preparedAttributes[$code] = $value;
380+
}
381+
return $preparedAttributes;
364382
}
365383
}

app/code/Magento/BundleImportExport/Test/Unit/Model/Export/Product/RowCustomizerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,16 @@ public function testAddHeaderColumns()
178178
public function testAddData()
179179
{
180180
$preparedData = $this->rowCustomizerMock->prepareData($this->productResourceCollection, [1]);
181-
$attributes = 'attribute=1,sku_type=1,price_type=1,price_view=1,weight_type=1,values=values,shipment_type=1';
181+
$attributes = 'attribute=1,sku_type=1,attribute2="Text",price_type=1,price_view=1,weight_type=1,'
182+
. 'values=values,shipment_type=1,attribute3=One,Two,Three';
182183
$dataRow = [
183184
'sku' => 'sku1',
184185
'additional_attributes' => $attributes
185186
];
186187
$preparedRow = $preparedData->addData($dataRow, 1);
187188
$expected = [
188189
'sku' => 'sku1',
189-
'additional_attributes' => 'attribute=1',
190+
'additional_attributes' => 'attribute=1,attribute2="Text",attribute3=One,Two,Three',
190191
'bundle_price_type' => 'fixed',
191192
'bundle_shipment_type' => 'separately',
192193
'bundle_sku_type' => 'fixed',

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testToHtml()
5353
->disableOriginalConstructor()
5454
->setMethods(['dispatch'])
5555
->getMock();
56-
$eventManager->expects($this->once())->method('dispatch')->will($this->returnValue(true));
56+
$eventManager->expects($this->exactly(2))->method('dispatch')->will($this->returnValue(true));
5757

5858
$scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class)
5959
->setMethods(['getValue'])

app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function testGetProductsCount()
186186

187187
protected function generalGetProductCollection()
188188
{
189-
$this->eventManager->expects($this->once())->method('dispatch')
189+
$this->eventManager->expects($this->exactly(2))->method('dispatch')
190190
->will($this->returnValue(true));
191191
$this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
192192
->willReturn(false);

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,20 +2416,34 @@ private function _parseAdditionalAttributes($rowData)
24162416
if (empty($rowData['additional_attributes'])) {
24172417
return $rowData;
24182418
}
2419+
$rowData = array_merge($rowData, $this->parseAdditionalAttributes($rowData['additional_attributes']));
2420+
return $rowData;
2421+
}
24192422

2420-
$attributeNameValuePairs = explode($this->getMultipleValueSeparator(), $rowData['additional_attributes']);
2421-
foreach ($attributeNameValuePairs as $attributeNameValuePair) {
2422-
$separatorPosition = strpos($attributeNameValuePair, self::PAIR_NAME_VALUE_SEPARATOR);
2423-
if ($separatorPosition !== false) {
2424-
$key = substr($attributeNameValuePair, 0, $separatorPosition);
2425-
$value = substr(
2426-
$attributeNameValuePair,
2427-
$separatorPosition + strlen(self::PAIR_NAME_VALUE_SEPARATOR)
2428-
);
2429-
$rowData[$key] = $value === false ? '' : $value;
2423+
/**
2424+
* Retrieves additional attributes as array code=>value.
2425+
*
2426+
* @param string $additionalAttributes
2427+
* @return array
2428+
*/
2429+
private function parseAdditionalAttributes($additionalAttributes)
2430+
{
2431+
$attributeNameValuePairs = explode($this->getMultipleValueSeparator(), $additionalAttributes);
2432+
$preparedAttributes = [];
2433+
$code = '';
2434+
foreach ($attributeNameValuePairs as $attributeData) {
2435+
//process case when attribute has ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR inside its value
2436+
if (strpos($attributeData, self::PAIR_NAME_VALUE_SEPARATOR) === false) {
2437+
if (!$code) {
2438+
continue;
2439+
}
2440+
$preparedAttributes[$code] .= $this->getMultipleValueSeparator() . $attributeData;
2441+
continue;
24302442
}
2443+
list($code, $value) = explode(self::PAIR_NAME_VALUE_SEPARATOR, $attributeData, 2);
2444+
$preparedAttributes[$code] = $value;
24312445
}
2432-
return $rowData;
2446+
return $preparedAttributes;
24332447
}
24342448

24352449
/**

app/code/Magento/CatalogInventory/Model/Stock/Status.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getWebsiteId()
100100
*/
101101
public function getStockId()
102102
{
103-
return $this->getData(self::KEY_WEBSITE_ID);
103+
return $this->getData(self::KEY_STOCK_ID);
104104
}
105105

106106
/**

app/code/Magento/CustomerImportExport/Model/Import/Customer.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,6 @@ protected function _prepareDataForUpdate(array $rowData)
370370

371371
// attribute values
372372
foreach (array_intersect_key($rowData, $this->_attributes) as $attributeCode => $value) {
373-
if ($newCustomer && !strlen($value)) {
374-
continue;
375-
}
376-
377373
$attributeParameters = $this->_attributes[$attributeCode];
378374
if ('select' == $attributeParameters['type']) {
379375
$value = isset($attributeParameters['options'][strtolower($value)])

app/code/Magento/Email/Model/AbstractTemplate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,13 +663,13 @@ public function getTemplateFilter()
663663
* Save current design config and replace with design config from specified store
664664
* Event is not dispatched.
665665
*
666-
* @param int|string $storeId
666+
* @param null|bool|int|string $storeId
667667
* @param string $area
668668
* @return void
669669
*/
670670
public function emulateDesign($storeId, $area = self::DEFAULT_DESIGN_AREA)
671671
{
672-
if ($storeId) {
672+
if ($storeId !== null && $storeId !== false) {
673673
// save current design settings
674674
$this->emulatedDesignConfig = clone $this->getDesignConfig();
675675
if (

app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,24 @@ public function testEmulateDesignAndRevertDesign()
331331
{
332332
$model = $this->getModelMock();
333333
$originalConfig = ['area' => 'some_area', 'store' => 1];
334-
$expectedConfig = ['area' => 'frontend', 'store' => 2];
335334
$model->setDesignConfig($originalConfig);
336335

337-
$model->emulateDesign(2);
338-
// assert config data has been emulated
339-
$this->assertEquals($expectedConfig, $model->getDesignConfig()->getData());
340-
341-
$model->revertDesign();
342-
// assert config data has been reverted to the original state
343-
$this->assertEquals($originalConfig, $model->getDesignConfig()->getData());
336+
$expectedConfigs = [
337+
['in' => ['area' => 'frontend', 'store' => null], 'out' => $originalConfig],
338+
['in' => ['area' => 'frontend', 'store' => false], 'out' => $originalConfig],
339+
['in' => ['area' => 'frontend', 'store' => 0], 'out' => ['area' => 'frontend', 'store' => 0]],
340+
['in' => ['area' => 'frontend', 'store' => 1], 'out' => ['area' => 'frontend', 'store' => 1]],
341+
['in' => ['area' => 'frontend', 'store' => 2], 'out' => ['area' => 'frontend', 'store' => 2]],
342+
];
343+
foreach ($expectedConfigs as $set) {
344+
$model->emulateDesign($set['in']['store'], $set['in']['area']);
345+
// assert config data has been emulated
346+
$this->assertEquals($set['out'], $model->getDesignConfig()->getData());
347+
348+
$model->revertDesign();
349+
// assert config data has been reverted to the original state
350+
$this->assertEquals($originalConfig, $model->getDesignConfig()->getData());
351+
}
344352
}
345353

346354
public function testGetDesignConfig()

app/code/Magento/Paypal/Model/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ public function isOrderReviewStepDisabled()
866866
*/
867867
public function getExpressCheckoutStartUrl($token)
868868
{
869-
return sprintf('https://www.%spaypal.com/checkoutnow/2%s',
869+
return sprintf('https://www.%spaypal.com/checkoutnow%s',
870870
$this->getValue('sandboxFlag') ? 'sandbox.' : '',
871871
'?token=' . urlencode($token));
872872
}

0 commit comments

Comments
 (0)