Skip to content

Commit 2680b71

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into PR-4
2 parents 211c549 + 964f540 commit 2680b71

File tree

7 files changed

+285
-12
lines changed

7 files changed

+285
-12
lines changed

app/code/Magento/Braintree/view/adminhtml/web/js/vault.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
define([
88
'jquery',
99
'uiComponent',
10-
'Magento_Ui/js/modal/alert',
11-
'Magento_Checkout/js/model/full-screen-loader'
12-
], function ($, Class, alert, fullScreenLoader) {
10+
'Magento_Ui/js/modal/alert'
11+
], function ($, Class, alert) {
1312
'use strict';
1413

1514
return Class.extend({
@@ -84,7 +83,7 @@ define([
8483
submitOrder: function () {
8584
this.$selector.validate().form();
8685
this.$selector.trigger('afterValidate.beforeSubmit');
87-
fullScreenLoader.stopLoader();
86+
$('body').trigger('processStop');
8887

8988
// validate parent form
9089
if (this.$selector.validate().errorList.length) {
@@ -106,7 +105,7 @@ define([
106105
getPaymentMethodNonce: function () {
107106
var self = this;
108107

109-
fullScreenLoader.startLoader();
108+
$('body').trigger('processStart');
110109

111110
$.get(self.nonceUrl, {
112111
'public_hash': self.publicHash
@@ -118,7 +117,7 @@ define([
118117

119118
self.error(failed.message);
120119
}).always(function () {
121-
fullScreenLoader.stopLoader();
120+
$('body').trigger('processStop');
122121
});
123122
},
124123

app/code/Magento/Bundle/Pricing/Price/FinalPrice.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
1111
use Magento\Catalog\Pricing\Price\CustomOptionPrice;
1212
use Magento\Bundle\Model\Product\Price;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
1315

1416
/**
1517
* Final price model
@@ -36,6 +38,11 @@ class FinalPrice extends \Magento\Catalog\Pricing\Price\FinalPrice implements Fi
3638
*/
3739
protected $bundleOptionPrice;
3840

41+
/**
42+
* @var \Magento\Catalog\Api\ProductCustomOptionRepositoryInterface
43+
*/
44+
private $productOptionRepository;
45+
3946
/**
4047
* @param Product $saleableItem
4148
* @param float $quantity
@@ -81,6 +88,22 @@ public function getMaximalPrice()
8188
return $this->maximalPrice;
8289
}
8390

91+
/**
92+
* Return ProductCustomOptionRepository
93+
*
94+
* @return ProductCustomOptionRepositoryInterface
95+
* @deprecated
96+
*/
97+
private function getProductOptionRepository()
98+
{
99+
if (!$this->productOptionRepository) {
100+
$this->productOptionRepository = ObjectManager::getInstance()->get(
101+
ProductCustomOptionRepositoryInterface::class
102+
);
103+
}
104+
return $this->productOptionRepository;
105+
}
106+
84107
/**
85108
* Returns min price
86109
*
@@ -101,6 +124,7 @@ public function getAmount()
101124
if (!$this->minimalPrice) {
102125
$price = parent::getValue();
103126
if ($this->product->getPriceType() == Price::PRICE_TYPE_FIXED) {
127+
$this->loadProductCustomOptions();
104128
/** @var \Magento\Catalog\Pricing\Price\CustomOptionPrice $customOptionPrice */
105129
$customOptionPrice = $this->priceInfo->getPrice(CustomOptionPrice::PRICE_CODE);
106130
$price += $customOptionPrice->getCustomOptionRange(true);
@@ -110,6 +134,23 @@ public function getAmount()
110134
return $this->minimalPrice;
111135
}
112136

137+
/**
138+
* Load product custom options
139+
*
140+
* @return void
141+
*/
142+
private function loadProductCustomOptions()
143+
{
144+
if (!$this->product->getOptions()) {
145+
$options = [];
146+
foreach ($this->getProductOptionRepository()->getProductOptions($this->product) as $option) {
147+
$option->setProduct($this->product);
148+
$options[] = $option;
149+
}
150+
$this->product->setOptions($options);
151+
}
152+
}
153+
113154
/**
114155
* get bundle product price without any option
115156
*

app/code/Magento/Bundle/Test/Unit/Pricing/Price/FinalPriceTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
use Magento\Bundle\Pricing\Price\BundleOptionPrice;
1010
use Magento\Catalog\Pricing\Price\CustomOptionPrice;
1111
use Magento\Bundle\Model\Product\Price;
12-
12+
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
13+
use Magento\Framework\Pricing\PriceCurrencyInterface;
1314
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1415

16+
/**
17+
* @SuppressWarnings(PHPMD)
18+
*/
1519
class FinalPriceTest extends \PHPUnit_Framework_TestCase
1620
{
1721
/** @var \Magento\Bundle\Pricing\Price\FinalPrice */
@@ -45,10 +49,15 @@ class FinalPriceTest extends \PHPUnit_Framework_TestCase
4549
protected $customOptionPriceMock;
4650

4751
/**
48-
* @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
52+
* @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
4953
*/
5054
protected $priceCurrencyMock;
5155

56+
/**
57+
* @var ProductCustomOptionRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
58+
*/
59+
private $productOptionRepositoryMock;
60+
5261
/**
5362
* @return void
5463
*/
@@ -96,6 +105,14 @@ protected function prepareMock()
96105
$this->bundleCalculatorMock,
97106
$this->priceCurrencyMock
98107
);
108+
109+
$this->productOptionRepositoryMock = $this->getMockForAbstractClass(
110+
ProductCustomOptionRepositoryInterface::class
111+
);
112+
$reflection = new \ReflectionClass(get_class($this->finalPrice));
113+
$reflectionProperty = $reflection->getProperty('productOptionRepository');
114+
$reflectionProperty->setAccessible(true);
115+
$reflectionProperty->setValue($this->finalPrice, $this->productOptionRepositoryMock);
99116
}
100117

101118
/**
@@ -172,6 +189,16 @@ public function testGetMinimalPriceFixedBundleWithOption()
172189
$this->baseAmount = 5;
173190
$result = 7;
174191
$this->prepareMock();
192+
$customOptions = [
193+
$this->getMockBuilder(\Magento\Catalog\Api\Data\ProductCustomOptionInterface::class)
194+
->setMethods(['setProduct'])
195+
->getMockForAbstractClass()
196+
];
197+
198+
$this->productOptionRepositoryMock->expects(static::once())
199+
->method('getProductOptions')
200+
->with($this->saleableInterfaceMock)
201+
->willReturn($customOptions);
175202

176203
$this->saleableInterfaceMock->expects($this->once())
177204
->method('getPriceType')

app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ protected function _construct()
100100
$this->setUseAjax(true);
101101
}
102102

103+
/**
104+
* Get grid url
105+
*
106+
* @return string
107+
*/
108+
public function getGridUrl()
109+
{
110+
return $this->getUrl('paypal/billing_agreement/ordersGrid', ['_current' => true]);
111+
}
112+
103113
/**
104114
* Apply various selection filters to prepare the sales order grid collection.
105115
*

app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_ordersgrid.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
<referenceBlock name="sales.order.grid.export" remove="true"/>
1919
<referenceBlock name="sales.order.grid.massaction" remove="true"/>
2020
<container name="root">
21-
<block class="Magento\Backend\Block\Widget\Grid\Container" name="sales_order.grid.container" template="Magento_Backend::widget/grid/container/empty.phtml"/>
21+
<block class="Magento\Paypal\Block\Adminhtml\Billing\Agreement\View\Tab\Orders" name="sales_order.grid.container"/>
2222
</container>
2323
</layout>

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public function getQuote()
145145
*/
146146
public function importData(array $data)
147147
{
148+
$data = $this->convertPaymentData($data);
148149
$data = new \Magento\Framework\DataObject($data);
149150
$this->_eventManager->dispatch(
150151
$this->_eventPrefix . '_import_data_before',
@@ -177,6 +178,37 @@ public function importData(array $data)
177178
return $this;
178179
}
179180

181+
/**
182+
* Converts request to payment data
183+
*
184+
* @param array $rawData
185+
* @return array
186+
*/
187+
private function convertPaymentData(array $rawData)
188+
{
189+
$paymentData = [
190+
PaymentInterface::KEY_METHOD => null,
191+
PaymentInterface::KEY_PO_NUMBER => null,
192+
PaymentInterface::KEY_ADDITIONAL_DATA => [],
193+
'checks' => []
194+
];
195+
196+
foreach (array_keys($rawData) as $requestKey) {
197+
if (!array_key_exists($requestKey, $paymentData)) {
198+
$paymentData[PaymentInterface::KEY_ADDITIONAL_DATA][$requestKey] = $rawData[$requestKey];
199+
} elseif ($requestKey === PaymentInterface::KEY_ADDITIONAL_DATA) {
200+
$paymentData[PaymentInterface::KEY_ADDITIONAL_DATA] = array_merge(
201+
$paymentData[PaymentInterface::KEY_ADDITIONAL_DATA],
202+
(array) $rawData[$requestKey]
203+
);
204+
} else {
205+
$paymentData[$requestKey] = $rawData[$requestKey];
206+
}
207+
}
208+
209+
return $paymentData;
210+
}
211+
180212
/**
181213
* Prepare object for save
182214
*
@@ -226,7 +258,7 @@ public function getOrderPlaceRedirectUrl()
226258
public function getMethodInstance()
227259
{
228260
$method = parent::getMethodInstance();
229-
$method->setStore($this->getQuote()->getStore()->getStoreId());
261+
$method->setStore($this->getQuote()->getStoreId());
230262
return $method;
231263
}
232264

0 commit comments

Comments
 (0)