Skip to content

Commit

Permalink
Merge pull request #49 from ihorvansach/34-remove-option-to-merge-gue…
Browse files Browse the repository at this point in the history
…st-cart-v2

34 remove option to merge guest cart v2
  • Loading branch information
naydav authored Apr 18, 2020
2 parents 7db6239 + 9a14167 commit 0f35ebd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
17 changes: 3 additions & 14 deletions app/code/Magento/LoginAsCustomer/Model/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Login extends \Magento\Framework\Model\AbstractModel
*/
const TIME_FRAME = 60;

const XML_PATH_KEEP_GUEST_CART = 'mfloginascustomer/general/keep_guest_cart';

/**
* Prefix of model events names
*
Expand Down Expand Up @@ -189,19 +187,10 @@ public function authenticateCustomer(): \Magento\Customer\Model\Customer
/* Logout if logged in */
$this->_customerSession->logout();
} else {

$quote = $this->cart->getQuote();

$keepItems = $this->scopeConfig->getValue(
self::XML_PATH_KEEP_GUEST_CART,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

if (!$keepItems) {
/* Remove items from guest cart */
foreach ($quote->getAllVisibleItems() as $item) {
$this->cart->removeItem($item->getId());
}
/* Remove items from guest cart */
foreach ($quote->getAllVisibleItems() as $item) {
$this->cart->removeItem($item->getId());
}
$this->cart->save();
}
Expand Down
15 changes: 5 additions & 10 deletions app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,23 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="mfloginascustomer" translate="label" type="text" sortOrder="1" showInDefault="1" >
<section id="mfloginascustomer" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>Login As Customer</label>
<tab>customer</tab>
<resource>Magento_LoginAsCustomer::config_section</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" canRestore="1">
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Login As Customer Information</label>
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" canRestore="1">
<field id="enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Extension</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="disable_page_cache" translate="label" type="select" sortOrder="20" showInDefault="1" canRestore="1">
<field id="disable_page_cache" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Disable Page Cache For Admin User</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[If set to "Yes", when login as customer Page Cache will be disabled.]]></comment>
</field>
<field id="keep_guest_cart" translate="label" type="select" sortOrder="30" showInDefault="1" canRestore="1">
<label>Keep Guest Shopping Cart Items</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[If set to "Yes", after login, guest shopping cart will be merged into customer shopping cart.]]></comment>
</field>
<field id="store_view_login" translate="label" type="select" sortOrder="40" showInDefault="1" canRestore="1">
<field id="store_view_login" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Store View To Login In</label>
<source_model>Magento\LoginAsCustomer\Model\Config\Source\StoreViewLogin</source_model>
<comment><![CDATA[
Expand Down

0 comments on commit 0f35ebd

Please sign in to comment.