Skip to content

Commit 8c91dde

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-89438
2 parents 748a9dc + a72f59b commit 8c91dde

File tree

132 files changed

+3483
-379
lines changed

Some content is hidden

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

132 files changed

+3483
-379
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ atlassian*
3333
/.php_cs
3434
/.php_cs.cache
3535
/grunt-config.json
36-
/dev/tools/grunt/configs/local-themes.js
3736

3837
/pub/media/*.*
3938
!/pub/media/.htaccess

app/code/Magento/Backend/Model/AdminPathConfig.php

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,38 @@ public function __construct(
4848
}
4949

5050
/**
51-
* {@inheritdoc}
52-
*
53-
* @param \Magento\Framework\App\RequestInterface $request
54-
* @return string
51+
* @inheritdoc
5552
*/
5653
public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
5754
{
5855
return $this->url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
5956
}
6057

6158
/**
62-
* {@inheritdoc}
63-
*
64-
* @param string $path
65-
* @return bool
59+
* @inheritdoc
6660
*/
6761
public function shouldBeSecure($path)
6862
{
69-
return parse_url(
70-
(string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default'),
71-
PHP_URL_SCHEME
72-
) === 'https'
73-
|| $this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)
74-
&& parse_url(
75-
(string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default'),
76-
PHP_URL_SCHEME
77-
) === 'https';
63+
$baseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
64+
if (parse_url($baseUrl, PHP_URL_SCHEME) === 'https') {
65+
return true;
66+
}
67+
68+
if ($this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)) {
69+
if ($this->backendConfig->isSetFlag('admin/url/use_custom')) {
70+
$adminBaseUrl = (string)$this->coreConfig->getValue('admin/url/custom', 'default');
71+
} else {
72+
$adminBaseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default');
73+
}
74+
75+
return parse_url($adminBaseUrl, PHP_URL_SCHEME) === 'https';
76+
}
77+
78+
return false;
7879
}
7980

8081
/**
81-
* {@inheritdoc}
82-
*
83-
* @return string
82+
* @inheritdoc
8483
*/
8584
public function getDefaultPath()
8685
{

app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,35 @@ public function testGetCurrentSecureUrl()
7676
* @param $unsecureBaseUrl
7777
* @param $useSecureInAdmin
7878
* @param $secureBaseUrl
79+
* @param $useCustomUrl
80+
* @param $customUrl
7981
* @param $expected
8082
* @dataProvider shouldBeSecureDataProvider
8183
*/
82-
public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureBaseUrl, $expected)
83-
{
84-
$coreConfigValueMap = [
84+
public function testShouldBeSecure(
85+
$unsecureBaseUrl,
86+
$useSecureInAdmin,
87+
$secureBaseUrl,
88+
$useCustomUrl,
89+
$customUrl,
90+
$expected
91+
) {
92+
$coreConfigValueMap = $this->returnValueMap([
8593
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default', null, $unsecureBaseUrl],
8694
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default', null, $secureBaseUrl],
87-
];
88-
$this->coreConfig->expects($this->any())->method('getValue')->will($this->returnValueMap($coreConfigValueMap));
89-
$this->backendConfig->expects($this->any())->method('isSetFlag')->willReturn($useSecureInAdmin);
95+
['admin/url/custom', 'default', null, $customUrl],
96+
]);
97+
$backendConfigFlagsMap = $this->returnValueMap([
98+
[\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, $useSecureInAdmin],
99+
['admin/url/use_custom', $useCustomUrl],
100+
]);
101+
$this->coreConfig->expects($this->atLeast(1))->method('getValue')
102+
->will($coreConfigValueMap);
103+
$this->coreConfig->expects($this->atMost(2))->method('getValue')
104+
->will($coreConfigValueMap);
105+
106+
$this->backendConfig->expects($this->atMost(2))->method('isSetFlag')
107+
->will($backendConfigFlagsMap);
90108
$this->assertEquals($expected, $this->adminPathConfig->shouldBeSecure(''));
91109
}
92110

@@ -96,13 +114,13 @@ public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureB
96114
public function shouldBeSecureDataProvider()
97115
{
98116
return [
99-
['http://localhost/', false, 'default', false],
100-
['http://localhost/', true, 'default', false],
101-
['https://localhost/', false, 'default', true],
102-
['https://localhost/', true, 'default', true],
103-
['http://localhost/', false, 'https://localhost/', false],
104-
['http://localhost/', true, 'https://localhost/', true],
105-
['https://localhost/', true, 'https://localhost/', true],
117+
['http://localhost/', false, 'default', false, '', false],
118+
['http://localhost/', true, 'default', false, '', false],
119+
['https://localhost/', false, 'default', false, '', true],
120+
['https://localhost/', true, 'default', false, '', true],
121+
['http://localhost/', false, 'https://localhost/', false, '', false],
122+
['http://localhost/', true, 'https://localhost/', false, '', true],
123+
['https://localhost/', true, 'https://localhost/', false, '', true],
106124
];
107125
}
108126

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
define([
88
'jquery',
99
'underscore',
10-
'mage/utils/wrapper',
1110
'Magento_Checkout/js/view/payment/default',
1211
'Magento_Braintree/js/view/payment/adapter',
1312
'Magento_Checkout/js/model/quote',
@@ -19,7 +18,6 @@ define([
1918
], function (
2019
$,
2120
_,
22-
wrapper,
2321
Component,
2422
Braintree,
2523
quote,
@@ -105,6 +103,12 @@ define([
105103
}
106104
});
107105

106+
quote.shippingAddress.subscribe(function () {
107+
if (self.isActive()) {
108+
self.reInitPayPal();
109+
}
110+
});
111+
108112
// for each component initialization need update property
109113
this.isReviewRequired(false);
110114
this.initClientConfig();
@@ -222,9 +226,8 @@ define([
222226

223227
/**
224228
* Re-init PayPal Auth Flow
225-
* @param {Function} callback - Optional callback
226229
*/
227-
reInitPayPal: function (callback) {
230+
reInitPayPal: function () {
228231
if (Braintree.checkout) {
229232
Braintree.checkout.teardown(function () {
230233
Braintree.checkout = null;
@@ -235,17 +238,6 @@ define([
235238
this.clientConfig.paypal.amount = this.grandTotalAmount;
236239
this.clientConfig.paypal.shippingAddressOverride = this.getShippingAddress();
237240

238-
if (callback) {
239-
this.clientConfig.onReady = wrapper.wrap(
240-
this.clientConfig.onReady,
241-
function (original, checkout) {
242-
this.clientConfig.onReady = original;
243-
original(checkout);
244-
callback();
245-
}.bind(this)
246-
);
247-
}
248-
249241
Braintree.setConfig(this.clientConfig);
250242
Braintree.setup();
251243
},
@@ -429,19 +421,17 @@ define([
429421
* Triggers when customer click "Continue to PayPal" button
430422
*/
431423
payWithPayPal: function () {
432-
this.reInitPayPal(function () {
433-
if (!additionalValidators.validate()) {
434-
return;
435-
}
424+
if (!additionalValidators.validate()) {
425+
return;
426+
}
436427

437-
try {
438-
Braintree.checkout.paypal.initAuthFlow();
439-
} catch (e) {
440-
this.messageContainer.addErrorMessage({
441-
message: $t('Payment ' + this.getTitle() + ' can\'t be initialized.')
442-
});
443-
}
444-
}.bind(this));
428+
try {
429+
Braintree.checkout.paypal.initAuthFlow();
430+
} catch (e) {
431+
this.messageContainer.addErrorMessage({
432+
message: $t('Payment ' + this.getTitle() + ' can\'t be initialized.')
433+
});
434+
}
445435
},
446436

447437
/**
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Bundle\Model\Plugin;
9+
10+
use Magento\Quote\Model\Quote\Item as OrigQuoteItem;
11+
use Magento\Quote\Model\Quote\Item\AbstractItem;
12+
use Magento\Framework\Serialize\SerializerInterface;
13+
14+
/**
15+
* Update prices stored in quote item options after calculating quote item's totals.
16+
*/
17+
class UpdatePriceInQuoteItemOptions
18+
{
19+
/**
20+
* @var SerializerInterface
21+
*/
22+
private $serializer;
23+
24+
/**
25+
* @param SerializerInterface $serializer
26+
*/
27+
public function __construct(SerializerInterface $serializer)
28+
{
29+
$this->serializer = $serializer;
30+
}
31+
32+
/**
33+
* Update price on quote item options level
34+
*
35+
* @param OrigQuoteItem $subject
36+
* @param AbstractItem $result
37+
* @return AbstractItem
38+
*
39+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
40+
*/
41+
public function afterCalcRowTotal(OrigQuoteItem $subject, AbstractItem $result): AbstractItem
42+
{
43+
$bundleAttributes = $result->getProduct()->getCustomOption('bundle_selection_attributes');
44+
if ($bundleAttributes !== null) {
45+
$actualAmount = $result->getPrice() * $result->getQty();
46+
$parsedValue = $this->serializer->unserialize($bundleAttributes->getValue());
47+
if (is_array($parsedValue) && array_key_exists('price', $parsedValue)) {
48+
$parsedValue['price'] = $actualAmount;
49+
}
50+
$bundleAttributes->setValue($this->serializer->serialize($parsedValue));
51+
}
52+
53+
return $result;
54+
}
55+
}

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
741741
$price = $product->getPriceModel()
742742
->getSelectionFinalTotalPrice($product, $selection, 0, $qty);
743743
$attributes = [
744-
'price' => $this->priceCurrency->convert($price),
744+
'price' => $price,
745745
'qty' => $qty,
746746
'option_label' => $selection->getOption()
747747
->getTitle(),
@@ -821,11 +821,11 @@ private function recursiveIntval(array $array)
821821
private function multiToFlatArray(array $array)
822822
{
823823
$flatArray = [];
824-
foreach ($array as $key => $value) {
824+
foreach ($array as $value) {
825825
if (is_array($value)) {
826826
$flatArray = array_merge($flatArray, $this->multiToFlatArray($value));
827827
} else {
828-
$flatArray[$key] = $value;
828+
$flatArray[] = $value;
829829
}
830830
}
831831

app/code/Magento/Bundle/Test/Mftf/ActionGroup/BundleProductsOnAdminActionGroup.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@
4747
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductDropdown"/>
4848
<click selector="{{AdminProductGridActionSection.addBundleProduct}}" stepKey="goToNewBundleProductPage"/>
4949
</actionGroup>
50+
51+
<actionGroup name="CreateBundleProductForTwoSimpleProductsWithRadioTypeOptions" extends="CreateBundleProductForTwoSimpleProducts">
52+
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="Radio Buttons" after="fillOptionTitle" stepKey="selectInputType"/>
53+
</actionGroup>
5054
</actionGroups>

app/code/Magento/Bundle/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,20 @@
2323
<waitForText userInput="{{quantity}}" selector="{{StorefrontMinicartSection.productCount}}" time="30" stepKey="assertProductCount"/>
2424
<see userInput="You added {{product.name}} to your shopping cart." selector="{{StorefrontMessagesSection.success}}" stepKey="seeSuccessMessage"/>
2525
</actionGroup>
26+
<!-- Add Bundle Product to Cart with specified currency -->
27+
<actionGroup name="StoreFrontAddProductToCartFromBundleWithCurrencyActionGroup">
28+
<arguments>
29+
<argument name="product"/>
30+
<argument name="currency" type="string" defaultValue="US Dollar"/>
31+
</arguments>
32+
<click selector="{{StorefrontHeaderCurrencySwitcherSection.currencyTrigger}}" stepKey="openCurrencyTrigger"/>
33+
<click selector="{{StorefrontHeaderCurrencySwitcherSection.currency(currency)}}" stepKey="chooseCurrency"/>
34+
<waitForPageLoad stepKey="waitForCurrencyChange"/>
35+
<click selector="{{StorefrontBundledSection.addToCart}}" stepKey="clickCustomize"/>
36+
<waitForPageLoad stepKey="waitForBundleOpen"/>
37+
<checkOption selector="{{StorefrontBundledSection.bundleOptionByName(product.name)}}" stepKey="chooseProduct"/>
38+
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="addToCartProduct"/>
39+
<waitForAjaxLoad stepKey="waitForLoad"/>
40+
<scrollToTopOfPage stepKey="scrollToTop"/>
41+
</actionGroup>
2642
</actionGroups>

app/code/Magento/Bundle/Test/Mftf/Data/BundleProductData.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<data key="name" unique="suffix">BundleProduct</data>
1818
<data key="sku" unique="suffix">BundleProduct</data>
1919
<data key="status">1</data>
20+
<data key="set">4</data>
21+
<data key="type">bundle</data>
2022
<data key="urlKey" unique="suffix">bundleproduct</data>
2123
<data key="visibility">4</data>
2224
<data key="option_title" unique="suffix">TestOption</data>

app/code/Magento/Bundle/Test/Mftf/Section/StorefrontBundledSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="StorefrontBundledSection">
1212
<element name="bundleOption" type="input" selector=".option:nth-of-type({{numOption}}) .choice:nth-of-type({{numOptionSelect}}) input" parameterized="true"/>
13+
<element name="bundleOptionByName" type="input" selector="//div[@class='field choice']//span[@class='product-name'][contains(text(),'{{name}}')]/../../../input" parameterized="true"/>
1314
<element name="addToCart" type="button" selector="#bundle-slide" timeout="30"/>
1415
<element name="addToCartConfigured" type="button" selector="#product-addtocart-button" timeout="30"/>
1516
<element name="updateCart" type="button" selector="#product-updatecart-button" timeout="30"/>

0 commit comments

Comments
 (0)