Skip to content

Commit 2e00a7f

Browse files
authored
Merge pull request #4561 from magento-performance/MC-18726-and-18727
Customer section 2.2
2 parents 6e21efb + d6bf60e commit 2e00a7f

File tree

5 files changed

+8
-37
lines changed

5 files changed

+8
-37
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,7 @@ define([
8787
data.shippingCarrierCode = quote.shippingMethod()['carrier_code'];
8888
}
8989

90-
if (!cartCache.isChanged('cartVersion', customerData.get('cart')()['data_id']) &&
91-
!cartCache.isChanged('shippingMethodCode', data.shippingMethodCode) &&
92-
!cartCache.isChanged('shippingCarrierCode', data.shippingCarrierCode) &&
93-
!cartCache.isChanged('address', address) &&
94-
cartCache.get('totals') &&
95-
!cartCache.isChanged('subtotal', parseFloat(quote.totals().subtotal))
96-
) {
97-
quote.setTotals(cartCache.get('totals'));
98-
} else {
99-
return loadFromServer(address);
100-
}
90+
return loadFromServer(address);
10191
}
10292
};
10393
});

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ define([
102102
self.isLoading(true);
103103
});
104104

105-
if (cartData().website_id !== window.checkout.websiteId ||
106-
cartData().store_id !== window.checkout.storeId
105+
if (cartData().website_id !== window.checkout.websiteId &&
106+
cartData().website_id !== undefined
107107
) {
108108
customerData.reload(['cart'], false);
109109
}

app/code/Magento/Persistent/Test/Mftf/Test/StorefrontQuoteShippingDataPersistedForGuestTest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454
<actionGroup ref="CustomerLogoutStorefrontActionGroup" stepKey="customerLogout"/>
5555
<resetCookie userInput="persistent_shopping_cart" stepKey="resetPersistentCookie"/>
5656
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="amOnHomePageAfterResetPersistentCookie"/>
57-
<!--Check that the minicart is empty-->
58-
<actionGroup ref="AssertMiniCartEmpty" after="amOnHomePageAfterResetPersistentCookie" stepKey="seeMinicartEmpty"/>
5957
<!--Step 4: Add the product to shopping cart and open cart-->
6058
<amOnPage url="{{StorefrontProductPage.url($$createProduct.custom_attributes[url_key]$$)}}" stepKey="navigateToProductPageAsGuestUser"/>
6159
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addProductToCartAsGuestUser">

app/code/Magento/Store/Model/StoreSwitcher/ManagePrivateContent.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ public function __construct(
3737
}
3838

3939
/**
40+
* Update version of private content on each store switch.
41+
*
4042
* @param StoreInterface $fromStore store where we came from
4143
* @param StoreInterface $targetStore store where to go to
4244
* @param string $redirectUrl original url requested for redirect after switching
45+
*
4346
* @return string redirect url
4447
* @throws CannotSwitchStoreException
4548
*/
@@ -53,7 +56,7 @@ public function switch(StoreInterface $fromStore, StoreInterface $targetStore, s
5356
->setHttpOnly(false);
5457
$this->cookieManager->setPublicCookie(
5558
\Magento\Framework\App\PageCache\Version::COOKIE_NAME,
56-
'should_be_updated',
59+
\uniqid('updated-', true),
5760
$publicCookieMetadata
5861
);
5962
} catch (\Exception $e) {

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ define([
2323
result = {
2424
totals: 10
2525
},
26-
totals = {
27-
grandTotal: 5
28-
},
2926
address = {
3027
countryId: 'US',
3128
region: null,
@@ -91,20 +88,6 @@ define([
9188

9289
describe('Magento_Checkout/js/model/cart/totals-processor/default', function () {
9390

94-
it('estimateTotals if data was cached', function () {
95-
spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'isChanged').and.returnValue(false);
96-
spyOn(mocks['Magento_Customer/js/customer-data'], 'get').and.returnValue(
97-
ko.observable({
98-
'data_id': 1
99-
})
100-
);
101-
spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'get').and.returnValue(totals);
102-
spyOn(mocks['mage/storage'], 'post');
103-
expect(defaultProcessor.estimateTotals(address)).toBeUndefined();
104-
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(totals);
105-
expect(mocks['mage/storage'].post).not.toHaveBeenCalled();
106-
});
107-
10891
it('estimateTotals if data wasn\'t cached and request was successfully sent', function () {
10992
var deferral = new $.Deferred();
11093

@@ -122,12 +105,10 @@ define([
122105
return deferral.resolve(result);
123106
});
124107
expect(defaultProcessor.estimateTotals(address)).toBe(deferral);
125-
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(totals);
108+
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(result);
126109
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(0)[0]).toBe(true);
127110
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(1)[0]).toBe(false);
128111
expect(mocks['mage/storage'].post).toHaveBeenCalled();
129-
expect(mocks['Magento_Checkout/js/model/cart/cache'].get).not.toHaveBeenCalled();
130-
expect(mocks['Magento_Checkout/js/model/cart/cache'].set).toHaveBeenCalledWith('cart-data', data);
131112
});
132113

133114
it('estimateTotals if data wasn\'t cached and request returns error', function () {
@@ -147,7 +128,6 @@ define([
147128
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(0)[0]).toBe(true);
148129
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(1)[0]).toBe(false);
149130
expect(mocks['mage/storage'].post).toHaveBeenCalled();
150-
expect(mocks['Magento_Checkout/js/model/cart/cache'].get).not.toHaveBeenCalled();
151131
expect(mocks['Magento_Checkout/js/model/error-processor'].process).toHaveBeenCalledWith('Error Message');
152132
});
153133
});

0 commit comments

Comments
 (0)