Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@W-14146755 lwrShippingItegSupportMGD #262

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

gkirpichnikov
Copy link

@gkirpichnikov gkirpichnikov commented Sep 22, 2023

@W-14146755 lwrShippingItegSupportMGD
https://gus.lightning.force.com/a07EE00001anW4xYAE

What does this PR do?

@W-14146755 lwrShippingItegSupportMGD

What issues does this PR fix or reference?

#, @@
@W-14146755 lwrShippingItegSupportMGD
https://gus.lightning.force.com/a07EE00001anW4xYAE

Functionality Before

<insert gif and/or summary>

Functionality After

<insert gif and/or summary>

How to Test/Testing Effort

<insert gif and/or summary>
The test is included in the PR

@salesforce-cla
Copy link

Thanks for the contribution! It looks like @gkirpichnikov is an internal user so signing the CLA is not required. However, we need to confirm this.

List<CartItem> cartItems = new List<CartItem>([SELECT CartDeliveryGroupId FROM CartItem WHERE CartId = :cartId]);

Set<Id> cartDeliveryGroupsIDs = new Set<Id>();
for(CartItem curCartItem : cartItems){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not do this. For large cart, this loop is very expensive. You should query from cartDeliveryGroup table directly to get cartDeliveryGroup IDs
SELECT Id from CartDeliveryGroup WHERE CartId = :cartId

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wei-liu-salesforce fixed (the flip side, we will now add methods to delivery groups even those that possibly have no items, but that is less an issue for demo code, as those are limited to 20)

@@ -30,12 +35,20 @@ global class B2CDeliverySample implements sfdc_checkout.CartShippingCharges {
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many times you call shippingOptionsAndRatesFromExternalService()? once or in a loop?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -82,6 +90,9 @@ global class B2CDeliverySample implements sfdc_checkout.CartShippingCharges {
request.setEndpoint(httpHost + '/calculate-shipping-rates-winter-21-with-lang?lang=' + siteLanguage);
request.setMethod('GET');
HttpResponse response = http.send(request);

System.debug('gal>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove debug ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gurpreetsainisalesforce done, thanks!

}


@isTest static void testIntegrationRunsSuccessfully() {
Test.startTest();
init();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init() is also called from setup()

Copy link
Author

@gkirpichnikov gkirpichnikov Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gurpreetsainisalesforce I'm aware, unfortunately those common 'static' variables in apex are actually 'null' if not explicitly populated; may be it use a different instance to run the setup and to run the test - not sure, anyway it is null whence the init is not called from the test

for (ShippingOptionsAndRatesFromExternalService shippingOption: shippingOptionsAndRatesFromExternalService) {
populateCartDeliveryGroupMethodWithShippingOptions(shippingOption, cartDeliveryGroupId, cartId);
for(CartDeliveryGroup curCartDeliveryGroup : cartDeliveryGroups){
populateCartDeliveryGroupMethodWithShippingOptions(shippingOption, curCartDeliveryGroup.Id, cartId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here before populating the cartDeliveryGroupMethods for a deliveryGroup, we need to check if there are any cartItems in the deliveryGroup, else we will have ShippingMethods for an emptyDeliveryGroup which is confusing

@tarcang
Copy link
Contributor

tarcang commented Dec 5, 2023

Hello @gkirpichnikov , what is the status with this work? I am ready to integrate this if everything is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants