Skip to content

Commit 7622645

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into publication
2 parents 2d5cb70 + 54d2d3a commit 7622645

File tree

81 files changed

+4482
-2183
lines changed

Some content is hidden

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

81 files changed

+4482
-2183
lines changed

app/code/Magento/Backend/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<default>
1010
<dev>
1111
<template>
12-
<minify_html>1</minify_html>
12+
<minify_html>0</minify_html>
1313
</template>
1414
</dev>
1515
<system>

app/code/Magento/Catalog/Model/Category/Attribute/Source/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
namespace Magento\Catalog\Model\Category\Attribute\Source;
77

8-
use Magento\Cms\Model\Resource\Block\Grid\CollectionFactory;
8+
use Magento\Cms\Model\Resource\Block\CollectionFactory;
99

1010
/**
1111
* Catalog category landing page attribute source

app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Page.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ class Page extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
1515
/**
1616
* Block collection factory
1717
*
18-
* @var \Magento\Cms\Model\Resource\Block\Grid\CollectionFactory
18+
* @var \Magento\Cms\Model\Resource\Block\CollectionFactory
1919
*/
2020
protected $_blockCollectionFactory;
2121

2222
/**
2323
* Construct
2424
*
25-
* @param \Magento\Cms\Model\Resource\Block\Grid\CollectionFactory $blockCollectionFactory
25+
* @param \Magento\Cms\Model\Resource\Block\CollectionFactory $blockCollectionFactory
2626
*/
27-
public function __construct(\Magento\Cms\Model\Resource\Block\Grid\CollectionFactory $blockCollectionFactory)
27+
public function __construct(\Magento\Cms\Model\Resource\Block\CollectionFactory $blockCollectionFactory)
2828
{
2929
$this->_blockCollectionFactory = $blockCollectionFactory;
3030
}

app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/PageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private function getMockedBlockCollectionFactory()
4545
{
4646
$mockedCollection = $this->getMockedCollection();
4747

48-
$mockBuilder = $this->getMockBuilder('Magento\Cms\Model\Resource\Block\Grid\CollectionFactory');
48+
$mockBuilder = $this->getMockBuilder('Magento\Cms\Model\Resource\Block\CollectionFactory');
4949
$mock = $mockBuilder->setMethods(['create'])
5050
->disableOriginalConstructor()
5151
->getMock();

app/code/Magento/Checkout/Block/Cart/Sidebar.php

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magento\Checkout\Block\Cart;
1010

1111
use Magento\Framework\View\Block\IdentityInterface;
12+
use Magento\Store\Model\ScopeInterface;
1213

1314
/**
1415
* Wishlist sidebar block
@@ -19,6 +20,7 @@ class Sidebar extends AbstractCart implements IdentityInterface
1920
* Xml pah to chackout sidebar count value
2021
*/
2122
const XML_PATH_CHECKOUT_SIDEBAR_COUNT = 'checkout/sidebar/count';
23+
const XML_PATH_CHECKOUT_SIDEBAR_DISPLAY = 'checkout/sidebar/display';
2224

2325
/**
2426
* @var \Magento\Catalog\Model\Resource\Url
@@ -73,7 +75,7 @@ public function getItemCount()
7375
if (is_null($count)) {
7476
$count = $this->_scopeConfig->getValue(
7577
self::XML_PATH_CHECKOUT_SIDEBAR_COUNT,
76-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
78+
ScopeInterface::SCOPE_STORE
7779
);
7880
$this->setData('item_count', $count);
7981
}
@@ -161,14 +163,43 @@ public function isPossibleOnepageCheckout()
161163
/**
162164
* Get one page checkout page url
163165
*
164-
* @return bool
165-
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
166+
* @return string
166167
*/
167168
public function getCheckoutUrl()
168169
{
169170
return $this->getUrl('checkout/onepage');
170171
}
171172

173+
/**
174+
* Get shoppinc cart page url
175+
*
176+
* @return string
177+
*/
178+
public function getShoppingCartUrl()
179+
{
180+
return $this->getUrl('checkout/cart');
181+
}
182+
183+
/**
184+
* Get update cart item url
185+
*
186+
* @return string
187+
*/
188+
public function getUpdateItemQtyUrl()
189+
{
190+
return $this->getUrl('checkout/sidebar/updateItemQty');
191+
}
192+
193+
/**
194+
* Get remove cart item url
195+
*
196+
* @return string
197+
*/
198+
public function getRemoveItemUrl()
199+
{
200+
return $this->getUrl('checkout/sidebar/removeItem');
201+
}
202+
172203
/**
173204
* Define if Mini Shopping Cart Pop-Up Menu enabled
174205
*
@@ -178,8 +209,8 @@ public function getCheckoutUrl()
178209
public function getIsNeedToDisplaySideBar()
179210
{
180211
return (bool)$this->_scopeConfig->getValue(
181-
'checkout/sidebar/display',
182-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
212+
self::XML_PATH_CHECKOUT_SIDEBAR_DISPLAY,
213+
ScopeInterface::SCOPE_STORE
183214
);
184215
}
185216

@@ -284,8 +315,24 @@ public function getIdentities()
284315
return $identities;
285316
}
286317

318+
/**
319+
* Retrieve subtotal block html
320+
*
321+
* @return string
322+
*/
287323
public function getTotalsHtml()
288324
{
289325
return $this->getLayout()->getBlock('checkout.cart.minicart.totals')->toHtml();
290326
}
327+
328+
/**
329+
* Retrieve items qty text
330+
*
331+
* @param int $qty
332+
* @return \Magento\Framework\Phrase
333+
*/
334+
public function getSummaryText($qty)
335+
{
336+
return ($qty == 1) ? __(' item') : __(' items');
337+
}
291338
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Checkout\Controller\Sidebar;
7+
8+
use Magento\Checkout\Model\Sidebar;
9+
use Magento\Framework\App\Action\Action;
10+
use Magento\Framework\App\Action\Context;
11+
use Magento\Framework\App\Response\Http;
12+
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\Json\Helper\Data;
14+
use Magento\Framework\View\Result\PageFactory;
15+
use Psr\Log\LoggerInterface;
16+
17+
class RemoveItem extends Action
18+
{
19+
/**
20+
* @var Sidebar
21+
*/
22+
protected $sidebar;
23+
24+
/**
25+
* @var LoggerInterface
26+
*/
27+
protected $logger;
28+
29+
/**
30+
* @var Data
31+
*/
32+
protected $jsonHelper;
33+
34+
/**
35+
* @var PageFactory
36+
*/
37+
protected $resultPageFactory;
38+
39+
/**
40+
* @param Context $context
41+
* @param Sidebar $sidebar
42+
* @param LoggerInterface $logger
43+
* @param Data $jsonHelper
44+
* @param PageFactory $resultPageFactory
45+
*/
46+
public function __construct(
47+
Context $context,
48+
Sidebar $sidebar,
49+
LoggerInterface $logger,
50+
Data $jsonHelper,
51+
PageFactory $resultPageFactory
52+
) {
53+
$this->sidebar = $sidebar;
54+
$this->logger = $logger;
55+
$this->jsonHelper = $jsonHelper;
56+
$this->resultPageFactory = $resultPageFactory;
57+
parent::__construct($context);
58+
}
59+
60+
/**
61+
* @return $this
62+
*/
63+
public function execute()
64+
{
65+
$itemId = (int)$this->getRequest()->getParam('item_id');
66+
try {
67+
$this->sidebar->checkQuoteItem($itemId);
68+
$this->sidebar->removeQuoteItem($itemId);
69+
return $this->jsonResponse();
70+
} catch (LocalizedException $e) {
71+
return $this->jsonResponse($e->getMessage());
72+
} catch (\Exception $e) {
73+
$this->logger->critical($e);
74+
return $this->jsonResponse($e->getMessage());
75+
}
76+
}
77+
78+
/**
79+
* Compile JSON response
80+
*
81+
* @param string $error
82+
* @return Http
83+
*/
84+
protected function jsonResponse($error = '')
85+
{
86+
$response = $this->sidebar->getResponseData($error);
87+
88+
if (empty($error)) {
89+
$resultPage = $this->resultPageFactory->create();
90+
$block = $resultPage->getLayout()->getBlock('minicart.content')->toHtml();
91+
$response['content'] = $block;
92+
}
93+
94+
return $this->getResponse()->representJson(
95+
$this->jsonHelper->jsonEncode($response)
96+
);
97+
}
98+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Checkout\Controller\Sidebar;
7+
8+
use Magento\Checkout\Model\Sidebar;
9+
use Magento\Framework\App\Action\Action;
10+
use Magento\Framework\App\Action\Context;
11+
use Magento\Framework\App\Response\Http;
12+
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\Json\Helper\Data;
14+
use Psr\Log\LoggerInterface;
15+
16+
class UpdateItemQty extends Action
17+
{
18+
/**
19+
* @var Sidebar
20+
*/
21+
protected $sidebar;
22+
23+
/**
24+
* @var LoggerInterface
25+
*/
26+
protected $logger;
27+
28+
/**
29+
* @var Data
30+
*/
31+
protected $jsonHelper;
32+
33+
/**
34+
* @param Context $context
35+
* @param Sidebar $sidebar
36+
* @param LoggerInterface $logger
37+
* @param Data $jsonHelper
38+
*/
39+
public function __construct(
40+
Context $context,
41+
Sidebar $sidebar,
42+
LoggerInterface $logger,
43+
Data $jsonHelper
44+
) {
45+
$this->sidebar = $sidebar;
46+
$this->logger = $logger;
47+
$this->jsonHelper = $jsonHelper;
48+
parent::__construct($context);
49+
}
50+
51+
/**
52+
* @return $this
53+
*/
54+
public function execute()
55+
{
56+
$itemId = (int)$this->getRequest()->getParam('item_id');
57+
$itemQty = (int)$this->getRequest()->getParam('item_qty');
58+
59+
try {
60+
$this->sidebar->checkQuoteItem($itemId);
61+
$this->sidebar->updateQuoteItem($itemId, $itemQty);
62+
return $this->jsonResponse();
63+
} catch (LocalizedException $e) {
64+
return $this->jsonResponse($e->getMessage());
65+
} catch (\Exception $e) {
66+
$this->logger->critical($e);
67+
return $this->jsonResponse($e->getMessage());
68+
}
69+
}
70+
71+
/**
72+
* Compile JSON response
73+
*
74+
* @param string $error
75+
* @return Http
76+
*/
77+
protected function jsonResponse($error = '')
78+
{
79+
return $this->getResponse()->representJson(
80+
$this->jsonHelper->jsonEncode($this->sidebar->getResponseData($error))
81+
);
82+
}
83+
}

app/code/Magento/Checkout/Model/Cart.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ protected function reinitializeState()
228228
{
229229
$quote = $this->getQuote()->setCheckoutMethod('');
230230
$this->_checkoutSession->setCartWasUpdated(true);
231+
// TODO: Move this logic to Multishipping module as plug-in.
231232
// reset for multiple address checkout
232-
if ($this->_checkoutSession->getCheckoutState() !== Session::CHECKOUT_STATE_BEGIN) {
233+
if ($this->_checkoutSession->getCheckoutState() !== Session::CHECKOUT_STATE_BEGIN
234+
&& $this->_checkoutSession->getCheckoutState() !== null) {
233235
$quote->removeAllAddresses()->removePayment();
234236
$this->_checkoutSession->resetCheckout();
235237
}

0 commit comments

Comments
 (0)