Skip to content
Snippets Groups Projects
Commit f1153723 authored by Maxim Medinskiy's avatar Maxim Medinskiy
Browse files

Merge remote-tracking branch 'origin/MAGETWO-44378' into BUGS

parents 62a253db 304f4444
Branches
No related merge requests found
...@@ -52,7 +52,11 @@ define([ ...@@ -52,7 +52,11 @@ define([
customer = customerData.get('customer'); customer = customerData.get('customer');
if (!customer().firstname && !cart().isGuestCheckoutAllowed) { if (!customer().firstname && !cart().isGuestCheckoutAllowed) {
authenticationPopup.showModal(); if (this.options.url.isRedirectRequired) {
location.href = this.options.url.loginUrl;
} else {
authenticationPopup.showModal();
}
return false; return false;
} }
......
...@@ -33,7 +33,9 @@ define([ ...@@ -33,7 +33,9 @@ define([
"url": { "url": {
"checkout": window.checkout.checkoutUrl, "checkout": window.checkout.checkoutUrl,
"update": window.checkout.updateItemQtyUrl, "update": window.checkout.updateItemQtyUrl,
"remove": window.checkout.removeItemUrl "remove": window.checkout.removeItemUrl,
"loginUrl": window.checkout.customerLoginUrl,
"isRedirectRequired": window.checkout.isRedirectRequired
}, },
"button": { "button": {
"checkout": "#top-cart-btn-checkout", "checkout": "#top-cart-btn-checkout",
......
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Customer\Model\Cart;
use Magento\Customer\Model\Checkout\ConfigProvider;
class ConfigPlugin
{
/**
* @var ConfigProvider
*/
protected $configProvider;
/**
* @param ConfigProvider $configProvider
*/
public function __construct(
ConfigProvider $configProvider
) {
$this->configProvider = $configProvider;
}
/**
* @param \Magento\Checkout\Block\Cart\Sidebar $subject
* @param array $result
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetConfig(\Magento\Checkout\Block\Cart\Sidebar $subject, array $result)
{
return array_merge_recursive($result, $this->configProvider->getConfig());
}
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Customer\Model\Checkout;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Customer\Model\Url;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\StoreManagerInterface;
class ConfigProvider implements ConfigProviderInterface
{
/**
* @var StoreManagerInterface
*/
protected $storeManager;
/**
* @var UrlInterface
*/
protected $urlBuilder;
/**
* @param UrlInterface $urlBuilder
* @param StoreManagerInterface $storeManager
*/
public function __construct(
UrlInterface $urlBuilder,
StoreManagerInterface $storeManager
) {
$this->urlBuilder = $urlBuilder;
$this->storeManager = $storeManager;
}
/**
* {@inheritdoc}
*/
public function getConfig()
{
return [
'customerLoginUrl' => $this->getLoginUrl(),
'isRedirectRequired' => $this->isRedirectRequired(),
];
}
/**
* Returns URL to login controller action
*
* @return string
*/
protected function getLoginUrl()
{
return $this->urlBuilder->getUrl(Url::ROUTE_ACCOUNT_LOGIN);
}
/**
* Whether redirect to login page is required
*
* @return bool
*/
protected function isRedirectRequired()
{
$baseUrl = $this->storeManager->getStore()->getBaseUrl();
if (strpos($this->getLoginUrl(), $baseUrl) !== false) {
return false;
}
return true;
}
}
...@@ -54,4 +54,7 @@ ...@@ -54,4 +54,7 @@
<type name="Magento\Customer\Controller\AccountInterface"> <type name="Magento\Customer\Controller\AccountInterface">
<plugin name="customer_account" type="Magento\Customer\Controller\Plugin\Account" /> <plugin name="customer_account" type="Magento\Customer\Controller\Plugin\Account" />
</type> </type>
<type name="Magento\Checkout\Block\Cart\Sidebar">
<plugin name="customer_cart" type="\Magento\Customer\Model\Cart\ConfigPlugin" />
</type>
</config> </config>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment