-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1230 from magento-south/BUGS
Bug fixes: - MAGETWO-59135 [Github] Customer session is shared for different customers on two websites #4842 #6468 - MAGETWO-67623 [M2EE 2.0.10] - Customer Segment - Multiple Select Attribute: MySQL Query Issue - MAGETWO-47607 [Github] Sitemap generation in wrong folder when vhost is connected to pub folder - MAGETWO-63159 Content staging value for fields are not saved in database - MAGETWO-62975 [FT] Functional test Magento\Customer\Test\TestCase\RegisterCustomerFrontendEntityTest is failed - MAGETWO-56156 [GITHUB] Using API cannot create Tax Rate with a zero rate #4873
- Loading branch information
Showing
56 changed files
with
2,253 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Customer\Block; | ||
|
||
/** | ||
* Class CustomerScopeData provide scope (website, store or store_group) information on front | ||
* Can be used, for example, on store front, in order to determine | ||
* that private cache invalid for current scope, by comparing | ||
* with appropriate value in store front private cache. | ||
* @api | ||
*/ | ||
class CustomerScopeData extends \Magento\Framework\View\Element\Template | ||
{ | ||
/** | ||
* @var \Magento\Framework\View\Element\Template\Context | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* @var \Magento\Framework\Json\EncoderInterface | ||
*/ | ||
private $jsonEncoder; | ||
|
||
/** | ||
* @param \Magento\Framework\View\Element\Template\Context $context | ||
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Framework\View\Element\Template\Context $context, | ||
\Magento\Framework\Json\EncoderInterface $jsonEncoder, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->storeManager = $context->getStoreManager(); | ||
$this->jsonEncoder = $jsonEncoder; | ||
} | ||
|
||
/** | ||
* Return id of current website | ||
* | ||
* Can be used when necessary to obtain website id of the current customer. | ||
* | ||
* @return integer | ||
*/ | ||
public function getWebsiteId() | ||
{ | ||
return (int)$this->_storeManager->getStore()->getWebsiteId(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
app/code/Magento/Customer/Test/Unit/Block/CustomerScopeDataTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Customer\Test\Unit\Block; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Store\Api\Data\StoreInterface; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
use Magento\Customer\Block\CustomerScopeData; | ||
use Magento\Framework\Json\EncoderInterface; | ||
|
||
class CustomerScopeDataTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var \Magento\Customer\Block\CustomerScopeData */ | ||
private $model; | ||
|
||
/** @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject */ | ||
private $contextMock; | ||
|
||
/** @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
private $storeManagerMock; | ||
|
||
/** @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
private $scopeConfigMock; | ||
|
||
/** @var \Magento\Framework\Json\EncoderInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
private $encoderMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->contextMock = $this->getMockBuilder(Context::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class) | ||
->getMock(); | ||
|
||
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class) | ||
->getMock(); | ||
|
||
$this->encoderMock = $this->getMockBuilder(EncoderInterface::class) | ||
->getMock(); | ||
|
||
$this->contextMock->expects($this->exactly(2)) | ||
->method('getStoreManager') | ||
->willReturn($this->storeManagerMock); | ||
|
||
$this->contextMock->expects($this->once()) | ||
->method('getScopeConfig') | ||
->willReturn($this->scopeConfigMock); | ||
|
||
$this->model = new CustomerScopeData( | ||
$this->contextMock, | ||
$this->encoderMock, | ||
[] | ||
); | ||
} | ||
|
||
public function testGetWebsiteId() | ||
{ | ||
$storeId = 1; | ||
|
||
$storeMock = $this->getMockBuilder(StoreInterface::class) | ||
->setMethods(['getWebsiteId']) | ||
->getMockForAbstractClass(); | ||
|
||
$storeMock->expects($this->any()) | ||
->method('getWebsiteId') | ||
->willReturn($storeId); | ||
|
||
$this->storeManagerMock->expects($this->any()) | ||
->method('getStore') | ||
->with(null) | ||
->willReturn($storeMock); | ||
|
||
$this->assertEquals($storeId, $this->model->getWebsiteId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/code/Magento/Customer/view/frontend/templates/js/customer-data/invalidation-rules.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
// @codingStandardsIgnoreFile | ||
?> | ||
<?php | ||
/* @var $block \Magento\Customer\Block\CustomerScopeData */ | ||
?> | ||
<script type="text/x-magento-init"> | ||
<?php | ||
/* @noEscape */ | ||
echo \Zend_Json::encode([ | ||
'*' => ['Magento_Customer/js/invalidation-processor' => [ | ||
'invalidationRules' => [ | ||
'website-rule' => [ | ||
'Magento_Customer/js/invalidation-rules/website-rule' => [ | ||
'scopeConfig' => [ | ||
'websiteId' => $block->getWebsiteId(), | ||
] | ||
] | ||
] | ||
] | ||
]], | ||
]); | ||
?> | ||
</script> |
41 changes: 41 additions & 0 deletions
41
app/code/Magento/Customer/view/frontend/web/js/invalidation-processor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'underscore', | ||
'uiElement', | ||
'Magento_Customer/js/customer-data' | ||
], function (_, Element, customerData) { | ||
'use strict'; | ||
|
||
return Element.extend({ | ||
/** | ||
* Initialize object | ||
*/ | ||
initialize: function () { | ||
this._super(); | ||
this.process(customerData); | ||
}, | ||
|
||
/** | ||
* Process all rules in loop, each rule can invalidate some sections in customer data | ||
* | ||
* @param {Object} customerDataObject | ||
*/ | ||
process: function (customerDataObject) { | ||
_.each(this.invalidationRules, function (rule, ruleName) { | ||
_.each(rule, function (ruleArgs, rulePath) { | ||
require([rulePath], function (Rule) { | ||
var currentRule = new Rule(ruleArgs); | ||
|
||
if (!_.isFunction(currentRule.process)) { | ||
throw new Error('Rule ' + ruleName + ' should implement invalidationProcessor interface'); | ||
} | ||
currentRule.process(customerDataObject); | ||
}); | ||
}); | ||
}); | ||
} | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
app/code/Magento/Customer/view/frontend/web/js/invalidation-rules/website-rule.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'uiClass' | ||
], function (Element) { | ||
'use strict'; | ||
|
||
return Element.extend({ | ||
|
||
defaults: { | ||
scopeConfig: {} | ||
}, | ||
|
||
/** | ||
* Takes website id from current customer data and compare it with current website id | ||
* If customer belongs to another scope, we need to invalidate current section | ||
* | ||
* @param {Object} customerData | ||
*/ | ||
process: function (customerData) { | ||
var customer = customerData.get('customer'); | ||
|
||
if (this.scopeConfig && customer() && | ||
~~customer().websiteId !== ~~this.scopeConfig.websiteId && ~~customer().websiteId !== 0) { | ||
customerData.reload(['customer']); | ||
} | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Robots\Block; | ||
|
||
use Magento\Framework\DataObject\IdentityInterface; | ||
use Magento\Framework\View\Element\AbstractBlock; | ||
use Magento\Framework\View\Element\Context; | ||
use Magento\Robots\Model\Config\Value; | ||
use Magento\Robots\Model\Robots; | ||
use Magento\Store\Model\StoreResolver; | ||
|
||
/** | ||
* Robots Block Class. | ||
* Prepares base content for robots.txt and implements Page Cache functionality. | ||
* | ||
* @api | ||
*/ | ||
class Data extends AbstractBlock implements IdentityInterface | ||
{ | ||
/** | ||
* @var Robots | ||
*/ | ||
private $robots; | ||
|
||
/** | ||
* @var StoreResolver | ||
*/ | ||
private $storeResolver; | ||
|
||
/** | ||
* @param Context $context | ||
* @param Robots $robots | ||
* @param StoreResolver $storeResolver | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Robots $robots, | ||
StoreResolver $storeResolver, | ||
array $data = [] | ||
) { | ||
$this->robots = $robots; | ||
$this->storeResolver = $storeResolver; | ||
|
||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* Retrieve base content for robots.txt file | ||
* | ||
* @return string | ||
*/ | ||
protected function _toHtml() | ||
{ | ||
return $this->robots->getData() . PHP_EOL; | ||
} | ||
|
||
/** | ||
* Get unique page cache identities | ||
* | ||
* @return array | ||
*/ | ||
public function getIdentities() | ||
{ | ||
return [ | ||
Value::CACHE_TAG . '_' . $this->storeResolver->getCurrentStoreId(), | ||
]; | ||
} | ||
} |
Oops, something went wrong.