Skip to content

Commit 2de5e40

Browse files
author
Oleksii Korshenko
committed
Merge remote-tracking branch 'origin/develop-prs' into MAGETWO-69452-PR-9754
2 parents c5b040c + 2b11431 commit 2de5e40

File tree

81 files changed

+2622
-318
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

+2622
-318
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,16 @@ public function getGridIdsJson()
275275
if (!$this->getUseSelectAll()) {
276276
return '';
277277
}
278-
279278
/** @var \Magento\Framework\Data\Collection $allIdsCollection */
280279
$allIdsCollection = clone $this->getParentBlock()->getCollection();
281-
$gridIds = $allIdsCollection->clear()->setPageSize(0)->getAllIds();
282-
280+
281+
if ($this->getMassactionIdField()) {
282+
$massActionIdField = $this->getMassactionIdField();
283+
} else {
284+
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
285+
}
286+
287+
$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
283288
if (!empty($gridIds)) {
284289
return join(",", $gridIds);
285290
}

app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,14 @@ public function getGridIdsJson()
274274

275275
/** @var \Magento\Framework\Data\Collection $allIdsCollection */
276276
$allIdsCollection = clone $this->getParentBlock()->getCollection();
277-
$gridIds = $allIdsCollection->clear()->setPageSize(0)->getAllIds();
277+
278+
if ($this->getMassactionIdField()) {
279+
$massActionIdField = $this->getMassactionIdField();
280+
} else {
281+
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
282+
}
283+
284+
$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
278285

279286
if (!empty($gridIds)) {
280287
return join(",", $gridIds);

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ public function testGetGridIdsJsonWithoutUseSelectAll()
132132
public function testGetGridIdsJsonWithUseSelectAll(array $items, $result)
133133
{
134134
$this->_block->setUseSelectAll(true);
135-
135+
136+
if ($this->_block->getMassactionIdField()) {
137+
$massActionIdField = $this->_block->getMassactionIdField();
138+
} else {
139+
$massActionIdField = $this->_block->getParentBlock()->getMassactionIdField();
140+
}
141+
136142
$collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
137143
->disableOriginalConstructor()
138144
->getMock();
@@ -141,15 +147,13 @@ public function testGetGridIdsJsonWithUseSelectAll(array $items, $result)
141147
->method('getCollection')
142148
->willReturn($collectionMock);
143149

144-
$collectionMock->expects($this->once())
145-
->method('clear')
146-
->willReturnSelf();
147150
$collectionMock->expects($this->once())
148151
->method('setPageSize')
149152
->with(0)
150153
->willReturnSelf();
151154
$collectionMock->expects($this->once())
152-
->method('getAllIds')
155+
->method('getColumnValues')
156+
->with($massActionIdField)
153157
->willReturn($items);
154158

155159
$this->assertEquals($result, $this->_block->getGridIdsJson());

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ public function testGetGridIdsJsonWithoutUseSelectAll()
237237
public function testGetGridIdsJsonWithUseSelectAll(array $items, $result)
238238
{
239239
$this->_block->setUseSelectAll(true);
240+
241+
if ($this->_block->getMassactionIdField()) {
242+
$massActionIdField = $this->_block->getMassactionIdField();
243+
} else {
244+
$massActionIdField = $this->_block->getParentBlock()->getMassactionIdField();
245+
}
240246

241247
$collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
242248
->disableOriginalConstructor()
@@ -245,16 +251,13 @@ public function testGetGridIdsJsonWithUseSelectAll(array $items, $result)
245251
$this->_gridMock->expects($this->once())
246252
->method('getCollection')
247253
->willReturn($collectionMock);
248-
249-
$collectionMock->expects($this->once())
250-
->method('clear')
251-
->willReturnSelf();
252254
$collectionMock->expects($this->once())
253255
->method('setPageSize')
254256
->with(0)
255257
->willReturnSelf();
256258
$collectionMock->expects($this->once())
257-
->method('getAllIds')
259+
->method('getColumnValues')
260+
->with($massActionIdField)
258261
->willReturn($items);
259262

260263
$this->assertEquals($result, $this->_block->getGridIdsJson());

app/code/Magento/Catalog/Block/Product/AbstractProduct.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template
9696
*/
9797
protected $stockRegistry;
9898

99+
/**
100+
* @var ImageBuilder
101+
*/
102+
protected $imageBuilder;
103+
99104
/**
100105
* @param Context $context
101106
* @param array $data

app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Magento\Framework\App\ObjectManager;
1414

1515
/**
16-
* @api
16+
* @deprecated robots.txt file is no longer stored in filesystem. It generates as response on request.
1717
*/
1818
class Robots extends \Magento\Framework\App\Config\Value
1919
{
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Block;
7+
8+
/**
9+
* Class CustomerScopeData provide scope (website, store or store_group) information on front
10+
* Can be used, for example, on store front, in order to determine
11+
* that private cache invalid for current scope, by comparing
12+
* with appropriate value in store front private cache.
13+
* @api
14+
*/
15+
class CustomerScopeData extends \Magento\Framework\View\Element\Template
16+
{
17+
/**
18+
* @var \Magento\Framework\View\Element\Template\Context
19+
*/
20+
private $storeManager;
21+
22+
/**
23+
* @var \Magento\Framework\Json\EncoderInterface
24+
*/
25+
private $jsonEncoder;
26+
27+
/**
28+
* @param \Magento\Framework\View\Element\Template\Context $context
29+
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
30+
* @param array $data
31+
*/
32+
public function __construct(
33+
\Magento\Framework\View\Element\Template\Context $context,
34+
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
35+
array $data = []
36+
) {
37+
parent::__construct($context, $data);
38+
$this->storeManager = $context->getStoreManager();
39+
$this->jsonEncoder = $jsonEncoder;
40+
}
41+
42+
/**
43+
* Return id of current website
44+
*
45+
* Can be used when necessary to obtain website id of the current customer.
46+
*
47+
* @return integer
48+
*/
49+
public function getWebsiteId()
50+
{
51+
return (int)$this->_storeManager->getStore()->getWebsiteId();
52+
}
53+
}

app/code/Magento/Customer/CustomerData/Customer.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class Customer implements SectionSourceInterface
1919
*/
2020
protected $currentCustomer;
2121

22+
/**
23+
* @var View
24+
*/
25+
private $customerViewHelper;
26+
2227
/**
2328
* @param CurrentCustomer $currentCustomer
2429
* @param View $customerViewHelper
@@ -39,10 +44,12 @@ public function getSectionData()
3944
if (!$this->currentCustomer->getCustomerId()) {
4045
return [];
4146
}
47+
4248
$customer = $this->currentCustomer->getCustomer();
4349
return [
4450
'fullname' => $this->customerViewHelper->getCustomerName($customer),
4551
'firstname' => $customer->getFirstname(),
52+
'websiteId' => $customer->getWebsiteId(),
4653
];
4754
}
4855
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Test\Unit\Block;
7+
8+
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
use Magento\Framework\View\Element\Template\Context;
10+
use Magento\Store\Api\Data\StoreInterface;
11+
use Magento\Store\Model\StoreManagerInterface;
12+
use Magento\Customer\Block\CustomerScopeData;
13+
use Magento\Framework\Json\EncoderInterface;
14+
15+
class CustomerScopeDataTest extends \PHPUnit_Framework_TestCase
16+
{
17+
/** @var \Magento\Customer\Block\CustomerScopeData */
18+
private $model;
19+
20+
/** @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject */
21+
private $contextMock;
22+
23+
/** @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
24+
private $storeManagerMock;
25+
26+
/** @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
27+
private $scopeConfigMock;
28+
29+
/** @var \Magento\Framework\Json\EncoderInterface|\PHPUnit_Framework_MockObject_MockObject */
30+
private $encoderMock;
31+
32+
protected function setUp()
33+
{
34+
$this->contextMock = $this->getMockBuilder(Context::class)
35+
->disableOriginalConstructor()
36+
->getMock();
37+
38+
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
39+
->getMock();
40+
41+
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
42+
->getMock();
43+
44+
$this->encoderMock = $this->getMockBuilder(EncoderInterface::class)
45+
->getMock();
46+
47+
$this->contextMock->expects($this->exactly(2))
48+
->method('getStoreManager')
49+
->willReturn($this->storeManagerMock);
50+
51+
$this->contextMock->expects($this->once())
52+
->method('getScopeConfig')
53+
->willReturn($this->scopeConfigMock);
54+
55+
$this->model = new CustomerScopeData(
56+
$this->contextMock,
57+
$this->encoderMock,
58+
[]
59+
);
60+
}
61+
62+
public function testGetWebsiteId()
63+
{
64+
$storeId = 1;
65+
66+
$storeMock = $this->getMockBuilder(StoreInterface::class)
67+
->setMethods(['getWebsiteId'])
68+
->getMockForAbstractClass();
69+
70+
$storeMock->expects($this->any())
71+
->method('getWebsiteId')
72+
->willReturn($storeId);
73+
74+
$this->storeManagerMock->expects($this->any())
75+
->method('getStore')
76+
->with(null)
77+
->willReturn($storeMock);
78+
79+
$this->assertEquals($storeId, $this->model->getWebsiteId());
80+
}
81+
}

app/code/Magento/Customer/view/frontend/layout/default.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
<block name="customer.customer.data"
4646
class="Magento\Customer\Block\CustomerData"
4747
template="Magento_Customer::js/customer-data.phtml"/>
48+
<block name="customer.data.invalidation.rules" class="Magento\Customer\Block\CustomerScopeData"
49+
template="Magento_Customer::js/customer-data/invalidation-rules.phtml"/>
4850
</referenceContainer>
4951
</body>
5052
</page>

0 commit comments

Comments
 (0)