Skip to content

Commit c0389a9

Browse files
author
Mohan Ahuja
committed
ACP2E-98: Customer with global account sharing has to login again in the secondary website when guest checkout is disabled
- Added view model for getting store config flag on the UI, removed code from block API code.
1 parent 1e7771a commit c0389a9

File tree

4 files changed

+44
-13
lines changed

4 files changed

+44
-13
lines changed

app/code/Magento/Customer/Block/Account/AuthenticationPopup.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,4 @@ public function getCustomerForgotPasswordUrl()
119119
{
120120
return $this->getUrl('customer/account/forgotpassword');
121121
}
122-
123-
/**
124-
* Get global account sharing is enabled or not
125-
*
126-
* @return string
127-
*/
128-
public function isGlobalScopeEnabled()
129-
{
130-
$shareConfig = \Magento\Framework\App\ObjectManager::getInstance()
131-
->get(\Magento\Customer\Model\Config\Share::class);
132-
return $shareConfig->isGlobalScope();
133-
}
134122
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\ViewModel\Customer;
8+
9+
use Magento\Customer\Model\Config\Share as ConfigShare;
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
12+
class StoreConfig implements ArgumentInterface
13+
{
14+
15+
/**
16+
* @var ConfigShare
17+
*/
18+
private ConfigShare $configShare;
19+
20+
/**
21+
* Constructor
22+
*
23+
* @param ConfigShare $configShare
24+
*/
25+
public function __construct(
26+
ConfigShare $configShare
27+
) {
28+
$this->configShare = $configShare;
29+
}
30+
31+
/**
32+
* Get global account sharing is enabled or not
33+
*
34+
* @return bool
35+
*/
36+
public function isGlobalScopeEnabled(): bool
37+
{
38+
return $this->configShare->isGlobalScope();
39+
}
40+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
</item>
3939
</item>
4040
</argument>
41+
<argument name="view_model" xsi:type="object">Magento\Customer\ViewModel\Customer\StoreConfig</argument>
4142
</arguments>
4243
</block>
4344
<block name="customer.section.config" class="Magento\Customer\Block\SectionConfig"

app/code/Magento/Customer/view/frontend/templates/account/authentication-popup.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
/** @var \Magento\Customer\Block\Account\AuthenticationPopup $block */
88
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
9+
/** @var Magento\Customer\ViewModel\Customer\StoreConfig $viewModel */
10+
$viewModel = $block->getViewModel();
911
?>
1012
<div id="authenticationPopup" data-bind="scope:'authenticationPopup', style: {display: 'none'}">
1113
<?php $scriptString = 'window.authenticationPopup = ' . /* @noEscape */ $block->getSerializedConfig(); ?>
@@ -21,7 +23,7 @@
2123
"Magento_Ui/js/block-loader": "<?= $block->escapeJs($block->escapeUrl($block->getViewFileUrl(
2224
'images/loader-1.gif'
2325
))) ?>"
24-
<?php if ($block->isGlobalScopeEnabled()): ?>
26+
<?php if ($viewModel->isGlobalScopeEnabled()): ?>
2527
,
2628
"Magento_Customer/js/customer-global-session-loader": {}
2729
<?php endif; ?>

0 commit comments

Comments
 (0)