Skip to content

Commit 72fb58e

Browse files
committed
Merge remote-tracking branch 'origin/develop' into MAGETWO-69859
2 parents 0843395 + d902e08 commit 72fb58e

File tree

67 files changed

+2624
-290
lines changed

Some content is hidden

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

67 files changed

+2624
-290
lines changed

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
{

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,15 @@ define([
9191
var productSku = this.variationsComponent().getProductValue('sku'),
9292
productPrice = this.variationsComponent().getProductPrice(),
9393
productWeight = this.variationsComponent().getProductValue('weight'),
94+
productName = this.variationsComponent().getProductValue('name'),
9495
variationsKeys = [],
9596
gridExisting = [],
9697
gridNew = [],
9798
gridDeleted = [];
9899

99100
this.variations = [];
100101
_.each(variations, function (options) {
101-
var product, images, sku, quantity, price, variation,
102+
var product, images, sku, name, quantity, price, variation,
102103
productId = this.variationsComponent().getProductIdByOptions(options);
103104

104105
if (productId) {
@@ -110,6 +111,9 @@ define([
110111
sku = productSku + _.reduce(options, function (memo, option) {
111112
return memo + '-' + option.label;
112113
}, '');
114+
name = productName + _.reduce(options, function (memo, option) {
115+
return memo + '-' + option.label;
116+
}, '');
113117
quantity = getSectionValue('quantity', options);
114118

115119
if (!quantity && productId) {
@@ -128,7 +132,7 @@ define([
128132
options: options,
129133
images: images,
130134
sku: sku,
131-
name: sku,
135+
name: name,
132136
quantity: quantity,
133137
price: price,
134138
productId: productId,
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>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
// @codingStandardsIgnoreFile
8+
?>
9+
<?php
10+
/* @var $block \Magento\Customer\Block\CustomerScopeData */
11+
?>
12+
<script type="text/x-magento-init">
13+
<?php
14+
/* @noEscape */
15+
echo \Zend_Json::encode([
16+
'*' => ['Magento_Customer/js/invalidation-processor' => [
17+
'invalidationRules' => [
18+
'website-rule' => [
19+
'Magento_Customer/js/invalidation-rules/website-rule' => [
20+
'scopeConfig' => [
21+
'websiteId' => $block->getWebsiteId(),
22+
]
23+
]
24+
]
25+
]
26+
]],
27+
]);
28+
?>
29+
</script>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'underscore',
7+
'uiElement',
8+
'Magento_Customer/js/customer-data'
9+
], function (_, Element, customerData) {
10+
'use strict';
11+
12+
return Element.extend({
13+
/**
14+
* Initialize object
15+
*/
16+
initialize: function () {
17+
this._super();
18+
this.process(customerData);
19+
},
20+
21+
/**
22+
* Process all rules in loop, each rule can invalidate some sections in customer data
23+
*
24+
* @param {Object} customerDataObject
25+
*/
26+
process: function (customerDataObject) {
27+
_.each(this.invalidationRules, function (rule, ruleName) {
28+
_.each(rule, function (ruleArgs, rulePath) {
29+
require([rulePath], function (Rule) {
30+
var currentRule = new Rule(ruleArgs);
31+
32+
if (!_.isFunction(currentRule.process)) {
33+
throw new Error('Rule ' + ruleName + ' should implement invalidationProcessor interface');
34+
}
35+
currentRule.process(customerDataObject);
36+
});
37+
});
38+
});
39+
}
40+
});
41+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'uiClass'
7+
], function (Element) {
8+
'use strict';
9+
10+
return Element.extend({
11+
12+
defaults: {
13+
scopeConfig: {}
14+
},
15+
16+
/**
17+
* Takes website id from current customer data and compare it with current website id
18+
* If customer belongs to another scope, we need to invalidate current section
19+
*
20+
* @param {Object} customerData
21+
*/
22+
process: function (customerData) {
23+
var customer = customerData.get('customer');
24+
25+
if (this.scopeConfig && customer() &&
26+
~~customer().websiteId !== ~~this.scopeConfig.websiteId && ~~customer().websiteId !== 0) {
27+
customerData.reload(['customer']);
28+
}
29+
}
30+
});
31+
});

app/code/Magento/Newsletter/view/frontend/templates/subscribe.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
?>
1212
<div class="block newsletter">
13-
<div class="title"><strong><?php /* @escapeNotVerified */ echo __('Newsletter') ?></strong></div>
13+
<div class="title"><strong><?php echo $block->escapeHtml(__('Newsletter')) ?></strong></div>
1414
<div class="content">
1515
<form class="form subscribe"
1616
novalidate

0 commit comments

Comments
 (0)