Skip to content

Commit 4ffe4e1

Browse files
author
okarpenko
committed
Merge branch 'develop' of https://github.corp.ebay.com/magento2/magento2ce into BUGS
2 parents 7c6e388 + 0d9ecaa commit 4ffe4e1

File tree

32 files changed

+2064
-560
lines changed

32 files changed

+2064
-560
lines changed

app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ define(
8080
});
8181
if (proceed) {
8282
quote.setPaymentMethod(methodData.method);
83+
//set the totals before setting PaymentData
84+
quote.setTotals(response);
8385
service.setSelectedPaymentData(methodData);
8486
service.setSelectedPaymentInfo(methodInfo);
85-
quote.setTotals(response);
8687
navigator.setCurrent('paymentMethod').goNext();
8788
}
8889
}

app/code/Magento/PageCache/Block/Javascript.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ public function getScriptOptions()
2727
),
2828
'handles' => $this->_layout->getUpdate()->getHandles(),
2929
'originalRequest' => [
30-
'route' => $this->getRequest()->getRouteName(),
30+
'route' => $this->getRequest()->getRouteName(),
3131
'controller' => $this->getRequest()->getControllerName(),
32-
'action' => $this->getRequest()->getActionName(),
32+
'action' => $this->getRequest()->getActionName(),
33+
'uri' => $this->getRequest()->getRequestUri(),
3334
],
3435
'versionCookieName' => \Magento\Framework\App\PageCache\Version::COOKIE_NAME
3536
];

app/code/Magento/PageCache/Controller/Block/Render.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ public function execute()
2424
$currentRoute = $this->getRequest()->getRouteName();
2525
$currentControllerName = $this->getRequest()->getControllerName();
2626
$currentActionName = $this->getRequest()->getActionName();
27+
$currentRequestUri = $this->getRequest()->getRequestUri();
2728

2829
$origRequest = $this->getRequest()->getParam('originalRequest');
2930
$origRequest = json_decode($origRequest, true);
3031
$this->getRequest()->setRouteName($origRequest['route']);
3132
$this->getRequest()->setControllerName($origRequest['controller']);
3233
$this->getRequest()->setActionName($origRequest['action']);
34+
$this->getRequest()->setRequestUri($origRequest['uri']);
35+
3336
/** @var \Magento\Framework\View\Element\BlockInterface[] $blocks */
3437
$blocks = $this->_getBlocks();
3538
$data = [];
@@ -41,6 +44,7 @@ public function execute()
4144
$this->getRequest()->setRouteName($currentRoute);
4245
$this->getRequest()->setControllerName($currentControllerName);
4346
$this->getRequest()->setActionName($currentActionName);
47+
$this->getRequest()->setRequestUri($currentRequestUri);
4448

4549
$this->getResponse()->setPrivateHeaders(\Magento\PageCache\Helper\Data::PRIVATE_MAX_AGE_CACHE);
4650
$this->translateInline->processResponseBody($data);

app/code/Magento/PageCache/Test/Unit/Block/JavascriptTest.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ protected function setUp()
5454
'getControllerName',
5555
'getModuleName',
5656
'getActionName',
57+
'getRequestUri',
5758
'getParam',
5859
'setParams',
5960
'getParams',
6061
'setModuleName',
6162
'isSecure',
6263
'setActionName',
64+
'setRequestUri',
6365
'getCookie'
6466
],
6567
[],
@@ -122,6 +124,9 @@ public function testGetScriptOptions($isSecure, $url, $expectedResult)
122124
$this->requestMock->expects($this->once())
123125
->method('getActionName')
124126
->will($this->returnValue('action'));
127+
$this->requestMock->expects($this->once())
128+
->method('getRequestUri')
129+
->will($this->returnValue('uri'));
125130
$this->urlBuilderMock->expects($this->once())
126131
->method('getUrl')
127132
->willReturn($url);
@@ -153,10 +158,11 @@ public function getScriptOptionsDataProvider()
153158
* @param string $route
154159
* @param string $controller
155160
* @param string $action
161+
* @param string $uri
156162
* @param string $expectedResult
157163
* @dataProvider getScriptOptionsPrivateContentDataProvider
158164
*/
159-
public function testGetScriptOptionsPrivateContent($url, $route, $controller, $action, $expectedResult)
165+
public function testGetScriptOptionsPrivateContent($url, $route, $controller, $action, $uri, $expectedResult)
160166
{
161167
$handles = [
162168
'some',
@@ -179,6 +185,10 @@ public function testGetScriptOptionsPrivateContent($url, $route, $controller, $a
179185
->method('getActionName')
180186
->will($this->returnValue($action));
181187

188+
$this->requestMock->expects($this->once())
189+
->method('getRequestUri')
190+
->will($this->returnValue($uri));
191+
182192
$this->urlBuilderMock->expects($this->once())
183193
->method('getUrl')
184194
->willReturn($url);
@@ -191,14 +201,17 @@ public function testGetScriptOptionsPrivateContent($url, $route, $controller, $a
191201

192202
public function getScriptOptionsPrivateContentDataProvider()
193203
{
204+
// @codingStandardsIgnoreStart
194205
return [
195206
'http' => [
196-
'url' => 'http://some-name.com/page_cache/block/render',
197-
'route' => 'route',
198-
'controller' => 'controller',
199-
'action' => 'action',
200-
'expectedResult' => '~"originalRequest":{"route":"route","controller":"controller","action":"action"}~'
207+
'url' => 'http://some-name.com/page_cache/block/render',
208+
'route' => 'route',
209+
'controller' => 'controller',
210+
'action' => 'action',
211+
'uri' => 'uri',
212+
'expectedResult' => '~"originalRequest":{"route":"route","controller":"controller","action":"action","uri":"uri"}~'
201213
],
202214
];
215+
//@codingStandardsIgnoreEnd
203216
}
204217
}

app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ public function testExecuteNotAjax()
8888
public function testExecuteNoParams()
8989
{
9090
$this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true));
91-
$this->requestMock->expects($this->at(8))
91+
$this->requestMock->expects($this->at(10))
9292
->method('getParam')
9393
->with($this->equalTo('blocks'), $this->equalTo(''))
9494
->will($this->returnValue(''));
95-
$this->requestMock->expects($this->at(9))
95+
$this->requestMock->expects($this->at(11))
9696
->method('getParam')
9797
->with($this->equalTo('handles'), $this->equalTo(''))
9898
->will($this->returnValue(''));
@@ -103,7 +103,7 @@ public function testExecute()
103103
{
104104
$blocks = ['block1', 'block2'];
105105
$handles = ['handle1', 'handle2'];
106-
$originalRequest = '{"route":"route","controller":"controller","action":"action"}';
106+
$originalRequest = '{"route":"route","controller":"controller","action":"action","uri":"uri"}';
107107
$expectedData = ['block1' => 'data1', 'block2' => 'data2'];
108108

109109
$blockInstance1 = $this->getMock(
@@ -136,15 +136,18 @@ public function testExecute()
136136
->method('getActionName')
137137
->will($this->returnValue('render'));
138138
$this->requestMock->expects($this->at(4))
139+
->method('getRequestUri')
140+
->will($this->returnValue('uri'));
141+
$this->requestMock->expects($this->at(5))
139142
->method('getParam')
140143
->with($this->equalTo('originalRequest'))
141144
->will($this->returnValue($originalRequest));
142145

143-
$this->requestMock->expects($this->at(8))
146+
$this->requestMock->expects($this->at(10))
144147
->method('getParam')
145148
->with($this->equalTo('blocks'), $this->equalTo(''))
146149
->will($this->returnValue(json_encode($blocks)));
147-
$this->requestMock->expects($this->at(9))
150+
$this->requestMock->expects($this->at(11))
148151
->method('getParam')
149152
->with($this->equalTo('handles'), $this->equalTo(''))
150153
->will($this->returnValue(json_encode($handles)));

app/code/Magento/Sales/etc/extension_attributes.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

app/code/Magento/Tax/Model/App/Action/ContextPlugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public function aroundDispatch(
8484
\Closure $proceed,
8585
\Magento\Framework\App\RequestInterface $request
8686
) {
87-
if (!$this->moduleManager->isEnabled('Magento_PageCache') ||
87+
if (!$this->customerSession->isLoggedIn() ||
88+
!$this->moduleManager->isEnabled('Magento_PageCache') ||
8889
!$this->cacheConfig->isEnabled() ||
8990
!$this->taxHelper->isCatalogPriceDisplayAffectedByTax()) {
9091
return $proceed($request);

app/code/Magento/Tax/Model/Observer.php

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ class Observer
2020
*/
2121
protected $_taxData;
2222

23-
/**
24-
* @var \Magento\Tax\Model\Sales\Order\TaxFactory
25-
*/
26-
protected $_orderTaxFactory;
27-
28-
/**
29-
* @var \Magento\Sales\Model\Order\Tax\ItemFactory
30-
*/
31-
protected $_taxItemFactory;
32-
3323
/**
3424
* @var \Magento\Tax\Model\Calculation
3525
*/
@@ -57,8 +47,6 @@ class Observer
5747

5848
/**
5949
* @param \Magento\Tax\Helper\Data $taxData
60-
* @param \Magento\Tax\Model\Sales\Order\TaxFactory $orderTaxFactory
61-
* @param \Magento\Sales\Model\Order\Tax\ItemFactory $taxItemFactory
6250
* @param \Magento\Tax\Model\Calculation $calculation
6351
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
6452
* @param \Magento\Tax\Model\Resource\Report\TaxFactory $reportTaxFactory
@@ -67,17 +55,13 @@ class Observer
6755
*/
6856
public function __construct(
6957
\Magento\Tax\Helper\Data $taxData,
70-
\Magento\Tax\Model\Sales\Order\TaxFactory $orderTaxFactory,
71-
\Magento\Sales\Model\Order\Tax\ItemFactory $taxItemFactory,
7258
\Magento\Tax\Model\Calculation $calculation,
7359
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
7460
\Magento\Tax\Model\Resource\Report\TaxFactory $reportTaxFactory,
7561
\Magento\Framework\Locale\ResolverInterface $localeResolver,
7662
\Magento\Framework\Registry $registry
7763
) {
7864
$this->_taxData = $taxData;
79-
$this->_orderTaxFactory = $orderTaxFactory;
80-
$this->_taxItemFactory = $taxItemFactory;
8165
$this->_calculation = $calculation;
8266
$this->_localeDate = $localeDate;
8367
$this->_reportTaxFactory = $reportTaxFactory;
@@ -114,145 +98,6 @@ public function salesEventConvertQuoteAddressToOrder(\Magento\Framework\Event\Ob
11498
}
11599
}
116100

117-
/**
118-
* Save order tax information
119-
*
120-
* @param \Magento\Framework\Event\Observer $observer
121-
* @return void
122-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
123-
* @SuppressWarnings(PHPMD.NPathComplexity)
124-
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
125-
*/
126-
public function salesEventOrderAfterSave(\Magento\Framework\Event\Observer $observer)
127-
{
128-
$order = $observer->getEvent()->getOrder();
129-
130-
if (!$order->getConvertingFromQuote() || $order->getAppliedTaxIsSaved()) {
131-
return;
132-
}
133-
134-
$taxesAttr = $order->getCustomAttribute('applied_taxes');
135-
if (is_null($taxesAttr) || !is_array($taxesAttr->getValue())) {
136-
$taxes = [];
137-
} else {
138-
$taxes = $taxesAttr->getValue();
139-
}
140-
141-
$getTaxesForItemsAttr = $order->getCustomAttribute('item_applied_taxes');
142-
if (is_null($getTaxesForItemsAttr) || !is_array($getTaxesForItemsAttr->getValue())) {
143-
$getTaxesForItems = [];
144-
} else {
145-
$getTaxesForItems = $getTaxesForItemsAttr->getValue();
146-
}
147-
148-
$ratesIdQuoteItemId = [];
149-
foreach ($getTaxesForItems as $taxesArray) {
150-
foreach ($taxesArray as $rates) {
151-
if (count($rates['rates']) == 1) {
152-
$ratesIdQuoteItemId[$rates['id']][] = [
153-
'id' => $rates['item_id'],
154-
'percent' => $rates['percent'],
155-
'code' => $rates['rates'][0]['code'],
156-
'associated_item_id' => $rates['associated_item_id'],
157-
'item_type' => $rates['item_type'],
158-
'amount' => $rates['amount'],
159-
'base_amount' => $rates['base_amount'],
160-
'real_amount' => $rates['amount'],
161-
'real_base_amount' => $rates['base_amount'],
162-
];
163-
} else {
164-
$percentSum = 0;
165-
foreach ($rates['rates'] as $rate) {
166-
$real_amount = $rates['amount'] * $rate['percent'] / $rates['percent'];
167-
$real_base_amount = $rates['base_amount'] * $rate['percent'] / $rates['percent'];
168-
$ratesIdQuoteItemId[$rates['id']][] = [
169-
'id' => $rates['item_id'],
170-
'percent' => $rate['percent'],
171-
'code' => $rate['code'],
172-
'associated_item_id' => $rates['associated_item_id'],
173-
'item_type' => $rates['item_type'],
174-
'amount' => $rates['amount'],
175-
'base_amount' => $rates['base_amount'],
176-
'real_amount' => $real_amount,
177-
'real_base_amount' => $real_base_amount,
178-
];
179-
$percentSum += $rate['percent'];
180-
}
181-
}
182-
}
183-
}
184-
185-
foreach ($taxes as $row) {
186-
$id = $row['id'];
187-
foreach ($row['rates'] as $tax) {
188-
if (is_null($row['percent'])) {
189-
$baseRealAmount = $row['base_amount'];
190-
} else {
191-
if ($row['percent'] == 0 || $tax['percent'] == 0) {
192-
continue;
193-
}
194-
$baseRealAmount = $row['base_amount'] / $row['percent'] * $tax['percent'];
195-
}
196-
$hidden = isset($row['hidden']) ? $row['hidden'] : 0;
197-
$priority = isset($tax['priority']) ? $tax['priority'] : 0;
198-
$position = isset($tax['position']) ? $tax['position'] : 0;
199-
$process = isset($row['process']) ? $row['process'] : 0;
200-
$data = [
201-
'order_id' => $order->getId(),
202-
'code' => $tax['code'],
203-
'title' => $tax['title'],
204-
'hidden' => $hidden,
205-
'percent' => $tax['percent'],
206-
'priority' => $priority,
207-
'position' => $position,
208-
'amount' => $row['amount'],
209-
'base_amount' => $row['base_amount'],
210-
'process' => $process,
211-
'base_real_amount' => $baseRealAmount,
212-
];
213-
214-
/** @var $orderTax \Magento\Tax\Model\Sales\Order\Tax */
215-
$orderTax = $this->_orderTaxFactory->create();
216-
$result = $orderTax->setData($data)->save();
217-
218-
if (isset($ratesIdQuoteItemId[$id])) {
219-
foreach ($ratesIdQuoteItemId[$id] as $quoteItemId) {
220-
if ($quoteItemId['code'] == $tax['code']) {
221-
$itemId = null;
222-
$associatedItemId = null;
223-
if (isset($quoteItemId['id'])) {
224-
//This is a product item
225-
$item = $order->getItemByQuoteItemId($quoteItemId['id']);
226-
$itemId = $item->getId();
227-
} elseif (isset($quoteItemId['associated_item_id'])) {
228-
//This item is associated with a product item
229-
$item = $order->getItemByQuoteItemId($quoteItemId['associated_item_id']);
230-
$associatedItemId = $item->getId();
231-
}
232-
233-
$data = [
234-
'item_id' => $itemId,
235-
'tax_id' => $result->getTaxId(),
236-
'tax_percent' => $quoteItemId['percent'],
237-
'associated_item_id' => $associatedItemId,
238-
'amount' => $quoteItemId['amount'],
239-
'base_amount' => $quoteItemId['base_amount'],
240-
'real_amount' => $quoteItemId['real_amount'],
241-
'real_base_amount' => $quoteItemId['real_base_amount'],
242-
'taxable_item_type' => $quoteItemId['item_type'],
243-
];
244-
/** @var $taxItem \Magento\Sales\Model\Order\Tax\Item */
245-
$taxItem = $this->_taxItemFactory->create();
246-
$taxItem->setData($data)->save();
247-
}
248-
}
249-
}
250-
}
251-
}
252-
253-
$order->setAppliedTaxIsSaved(true);
254-
}
255-
256101
/**
257102
* Refresh sales tax report statistics for last day
258103
*

0 commit comments

Comments
 (0)