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
}

app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,14 @@ public function testGetWizardPaymentMethodOptions()
235235
public function testToHtml()
236236
{
237237
$this->eventManager
238-
->expects($this->once())
238+
->expects($this->at(0))
239239
->method('dispatch')
240240
->with('view_block_abstract_to_html_before', ['block' => $this->block]);
241+
$transport = new \Magento\Framework\DataObject(['html' => '']);
242+
$this->eventManager
243+
->expects($this->at(1))
244+
->method('dispatch')
245+
->with('view_block_abstract_to_html_after', ['block' => $this->block, 'transport' => $transport]);
241246
$this->scopeConfig
242247
->expects($this->once())
243248
->method('getValue')

app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,12 @@ public function testToHtml($customerId)
261261
$this->additional->setData('cache_lifetime', 789);
262262
$this->additional->setData('cache_key', 'cache-key');
263263

264-
$this->eventManagerMock->expects($this->once())
264+
$this->eventManagerMock->expects($this->at(0))
265265
->method('dispatch')
266266
->with('view_block_abstract_to_html_before', ['block' => $this->additional]);
267+
$this->eventManagerMock->expects($this->at(1))
268+
->method('dispatch')
269+
->with('view_block_abstract_to_html_after');
267270
$this->scopeConfigMock->expects($this->once())
268271
->method('getValue')
269272
->with(

app/code/Magento/Quote/Model/Quote/Payment.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class Payment extends \Magento\Payment\Model\Info implements PaymentInterface
6060
*/
6161
protected $methodSpecificationFactory;
6262

63+
/**
64+
* @var array
65+
*/
66+
private $additionalChecks;
67+
6368
/**
6469
* @param \Magento\Framework\Model\Context $context
6570
* @param \Magento\Framework\Registry $registry
@@ -71,6 +76,7 @@ class Payment extends \Magento\Payment\Model\Info implements PaymentInterface
7176
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
7277
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
7378
* @param array $data
79+
* @param array $additionalChecks
7480
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
7581
*/
7682
public function __construct(
@@ -83,9 +89,11 @@ public function __construct(
8389
\Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory,
8490
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
8591
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
86-
array $data = []
92+
array $data = [],
93+
array $additionalChecks = []
8794
) {
8895
$this->methodSpecificationFactory = $methodSpecificationFactory;
96+
$this->additionalChecks = $additionalChecks;
8997
parent::__construct(
9098
$context,
9199
$registry,
@@ -162,7 +170,8 @@ public function importData(array $data)
162170
*/
163171
$quote->collectTotals();
164172

165-
$methodSpecification = $this->methodSpecificationFactory->create($data->getChecks());
173+
$checks = array_merge($data->getChecks(), $this->additionalChecks);
174+
$methodSpecification = $this->methodSpecificationFactory->create($checks);
166175
if (!$method->isAvailable($quote) || !$methodSpecification->isApplicable($method, $quote)) {
167176
throw new \Magento\Framework\Exception\LocalizedException(
168177
__('The requested Payment Method is not available.')

app/code/Magento/Vault/Setup/UpgradeData.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Vault\Setup;
77

8+
use Magento\Framework\App\ObjectManager;
9+
use Magento\Framework\App\ResourceConnection;
10+
use Magento\Framework\DB\Adapter\AdapterInterface;
811
use Magento\Framework\Setup\ModuleContextInterface;
912
use Magento\Framework\Setup\ModuleDataSetupInterface;
1013
use Magento\Framework\Setup\UpgradeDataInterface;
@@ -16,13 +19,18 @@
1619
*/
1720
class UpgradeData implements UpgradeDataInterface
1821
{
22+
/**
23+
* @var AdapterInterface
24+
*/
25+
private $connection;
26+
1927
/**
2028
* @inheritdoc
2129
*/
2230
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
2331
{
2432
$setup->startSetup();
25-
$connection = $setup->getConnection();
33+
$connection = $this->getConnection();
2634

2735
// data update for Vault module < 2.0.1
2836
if (version_compare($context->getVersion(), '2.0.1', '<')) {
@@ -59,4 +67,23 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
5967

6068
$setup->endSetup();
6169
}
70+
71+
/**
72+
* Tries to get connection for scalable sales DB, otherwise returns default connection
73+
* @return AdapterInterface
74+
*/
75+
private function getConnection()
76+
{
77+
if ($this->connection === null) {
78+
/** @var ResourceConnection $conn */
79+
$conn = ObjectManager::getInstance()->get(ResourceConnection::class);
80+
try {
81+
$this->connection = $conn->getConnectionByName('sales');
82+
} catch (\DomainException $e) {
83+
$this->connection = $conn->getConnection();
84+
}
85+
}
86+
87+
return $this->connection;
88+
}
6289
}

app/code/Magento/Widget/Test/Unit/Block/Adminhtml/Widget/Instance/Edit/Chooser/ContainerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testToHtmlCatalogProductsListGroupedProduct()
6666
. 'Main Content Area</option><option value="content.bottom" >Main Content Bottom</option>'
6767
. '<option value="content.top" >Main Content Top</option></select>';
6868

69-
$this->eventManagerMock->expects($this->once())->method('dispatch')->willReturn(true);
69+
$this->eventManagerMock->expects($this->exactly(2))->method('dispatch')->willReturn(true);
7070
$this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false);
7171

7272
$this->themeCollectionFactoryMock->expects($this->once())
@@ -153,7 +153,7 @@ public function testToHtmlCatalogCategoryLinkSimpleProduct()
153153
. '<option value="sidebar.additional" >Sidebar Additional</option>'
154154
. '<option value="sidebar.main" >Sidebar Main</option></select>';
155155

156-
$this->eventManagerMock->expects($this->once())->method('dispatch')->willReturn(true);
156+
$this->eventManagerMock->expects($this->exactly(2))->method('dispatch')->willReturn(true);
157157
$this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false);
158158

159159
$this->themeCollectionFactoryMock->expects($this->once())
@@ -284,7 +284,7 @@ public function testToHtmlCmsStaticBlockAllProductTypes()
284284
. '<option value="sidebar.additional" >Sidebar Additional</option>'
285285
. '<option value="sidebar.main" >Sidebar Main</option></select>';
286286

287-
$this->eventManagerMock->expects($this->once())->method('dispatch')->willReturn(true);
287+
$this->eventManagerMock->expects($this->exactly(2))->method('dispatch')->willReturn(true);
288288
$this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false);
289289

290290
$this->themeCollectionFactoryMock->expects($this->once())
@@ -402,7 +402,7 @@ public function testToHtmlOrderBySkuAllPages()
402402
. '<option value="sidebar.additional" >Sidebar Additional</option><option value="sidebar.main" >'
403403
. 'Sidebar Main</option></select>';
404404

405-
$this->eventManagerMock->expects($this->once())->method('dispatch')->willReturn(true);
405+
$this->eventManagerMock->expects($this->exactly(2))->method('dispatch')->willReturn(true);
406406
$this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false);
407407

408408
$this->themeCollectionFactoryMock->expects($this->once())

0 commit comments

Comments
 (0)