Skip to content

Commit 15620c4

Browse files
author
Oleksii Korshenko
authored
Merge pull request #500 from magento-firedrakes/MAGETWO-59675
Deliver changes from 2.1.3 to 2.1-develop branch
2 parents 1ec4e0e + be2f4c7 commit 15620c4

File tree

331 files changed

+15573
-1811
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

331 files changed

+15573
-1811
lines changed

.php_cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ return Symfony\CS\Config\Config::create()
3333
'extra_empty_lines',
3434
'include',
3535
'join_function',
36-
'multiline_array_trailing_comma',
3736
'namespace_no_leading_whitespace',
3837
'new_with_braces',
3938
'object_operator',

app/code/Magento/Backend/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
<resource>Magento_Config::config_general</resource>
199199
<group id="country" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
200200
<label>Country Options</label>
201-
<field id="allow" translate="label" type="multiselect" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
201+
<field id="allow" translate="label" type="multiselect" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
202202
<label>Allow Countries</label>
203203
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
204204
<can_be_empty>1</can_be_empty>

app/code/Magento/Braintree/Gateway/Config/Config.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,14 @@ public function isActive()
169169
{
170170
return (bool) $this->getValue(self::KEY_ACTIVE);
171171
}
172+
173+
/**
174+
* Get Merchant account ID
175+
*
176+
* @return string
177+
*/
178+
public function getMerchantAccountId()
179+
{
180+
return $this->getValue(self::KEY_MERCHANT_ACCOUNT_ID);
181+
}
172182
}

app/code/Magento/Braintree/Gateway/Request/PaymentDataBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function build(array $buildSubject)
8787
self::ORDER_ID => $order->getOrderIncrementId()
8888
];
8989

90-
$merchantAccountId = $this->config->getValue(Config::KEY_MERCHANT_ACCOUNT_ID);
90+
$merchantAccountId = $this->config->getMerchantAccountId();
9191
if (!empty($merchantAccountId)) {
9292
$result[self::MERCHANT_ACCOUNT_ID] = $merchantAccountId;
9393
}

app/code/Magento/Braintree/Model/Ui/ConfigProvider.php

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

8+
use Magento\Braintree\Gateway\Request\PaymentDataBuilder;
89
use Magento\Checkout\Model\ConfigProviderInterface;
910
use Magento\Braintree\Gateway\Config\Config;
1011
use Magento\Braintree\Gateway\Config\PayPal\Config as PayPalConfig;
@@ -116,7 +117,14 @@ public function getConfig()
116117
public function getClientToken()
117118
{
118119
if (empty($this->clientToken)) {
119-
$this->clientToken = $this->adapter->generate();
120+
$params = [];
121+
122+
$merchantAccountId = $this->config->getMerchantAccountId();
123+
if (!empty($merchantAccountId)) {
124+
$params[PaymentDataBuilder::MERCHANT_ACCOUNT_ID] = $merchantAccountId;
125+
}
126+
127+
$this->clientToken = $this->adapter->generate($params);
120128
}
121129

122130
return $this->clientToken;

app/code/Magento/Braintree/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ public function testBuild()
133133
->willReturnMap($additionalData);
134134

135135
$this->configMock->expects(static::once())
136-
->method('getValue')
137-
->with(Config::KEY_MERCHANT_ACCOUNT_ID)
136+
->method('getMerchantAccountId')
138137
->willReturn(self::MERCHANT_ACCOUNT_ID);
139138

140139
$this->paymentDO->expects(static::once())

app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
class ConfigProviderTest extends \PHPUnit_Framework_TestCase
2020
{
2121
const SDK_URL = 'https://js.braintreegateway.com/v2/braintree.js';
22-
2322
const CLIENT_TOKEN = 'token';
23+
const MERCHANT_ACCOUNT_ID = '245345';
2424

2525
/**
2626
* @var Config|\PHPUnit_Framework_MockObject_MockObject
@@ -115,11 +115,17 @@ public function testGetConfig($config, $expected)
115115

116116
/**
117117
* @covers \Magento\Braintree\Model\Ui\ConfigProvider::getClientToken
118+
* @dataProvider getClientTokenDataProvider
118119
*/
119-
public function testGetClientToken()
120+
public function testGetClientToken($merchantAccountId, $params)
120121
{
122+
$this->config->expects(static::once())
123+
->method('getMerchantAccountId')
124+
->willReturn($merchantAccountId);
125+
121126
$this->braintreeAdapter->expects(static::once())
122127
->method('generate')
128+
->with($params)
123129
->willReturn(self::CLIENT_TOKEN);
124130

125131
static::assertEquals(self::CLIENT_TOKEN, $this->configProvider->getClientToken());
@@ -188,4 +194,21 @@ public function getConfigDataProvider()
188194
]
189195
];
190196
}
197+
198+
/**
199+
* @return array
200+
*/
201+
public function getClientTokenDataProvider()
202+
{
203+
return [
204+
[
205+
'merchantAccountId' => '',
206+
'params' => []
207+
],
208+
[
209+
'merchantAccountId' => self::MERCHANT_ACCOUNT_ID,
210+
'params' => ['merchantAccountId' => self::MERCHANT_ACCOUNT_ID]
211+
]
212+
];
213+
}
191214
}

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

Lines changed: 30 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,37 @@ 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+
if (strpos($attributeData, ImportProductModel::PAIR_NAME_VALUE_SEPARATOR) === false) {
371+
if (!$code) {
372+
continue;
373+
}
374+
$preparedAttributes[$code] .= ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR . $attributeData;
375+
continue;
376+
}
377+
list($code, $value) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attributeData, 2);
378+
$preparedAttributes[$code] = $value;
379+
}
380+
return $preparedAttributes;
364381
}
365382
}

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/CacheInvalidate/Observer/InvalidateVarnishObserver.php

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ class InvalidateVarnishObserver implements ObserverInterface
2121
*/
2222
protected $purgeCache;
2323

24+
/**
25+
* Invalidation tags resolver
26+
*
27+
* @var \Magento\Framework\App\Cache\Tag\Resolver
28+
*/
29+
private $tagResolver;
30+
2431
/**
2532
* @param \Magento\PageCache\Model\Config $config
2633
* @param \Magento\CacheInvalidate\Model\PurgeCache $purgeCache
@@ -42,18 +49,35 @@ public function __construct(
4249
*/
4350
public function execute(\Magento\Framework\Event\Observer $observer)
4451
{
52+
$object = $observer->getEvent()->getObject();
53+
if (!is_object($object)) {
54+
return;
55+
}
4556
if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled()) {
46-
$object = $observer->getEvent()->getObject();
47-
if ($object instanceof \Magento\Framework\DataObject\IdentityInterface) {
48-
$tags = [];
49-
$pattern = "((^|,)%s(,|$))";
50-
foreach ($object->getIdentities() as $tag) {
51-
$tags[] = sprintf($pattern, $tag);
52-
}
53-
if (!empty($tags)) {
54-
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
55-
}
57+
$bareTags = $this->getTagResolver()->getTags($object);
58+
59+
$tags = [];
60+
$pattern = "((^|,)%s(,|$))";
61+
foreach ($bareTags as $tag) {
62+
$tags[] = sprintf($pattern, $tag);
63+
}
64+
if (!empty($tags)) {
65+
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
5666
}
67+
68+
}
69+
}
70+
71+
/**
72+
* @deprecated
73+
* @return \Magento\Framework\App\Cache\Tag\Resolver
74+
*/
75+
private function getTagResolver()
76+
{
77+
if ($this->tagResolver === null) {
78+
$this->tagResolver = \Magento\Framework\App\ObjectManager::getInstance()
79+
->get(\Magento\Framework\App\Cache\Tag\Resolver::class);
5780
}
81+
return $this->tagResolver;
5882
}
5983
}

0 commit comments

Comments
 (0)