Skip to content

Conversation

@senthilengg
Copy link

Description (*)

  • Trigger CollectTotals only if the below condition are true
  • Quote is not virtual
  • Check GraphQl ResolverInfo OperationType is not "query"

Fixed Issues (if relevant)

  1. Fixes Cart Query >> CartPrice GraphQl Performance Optimisation #40209

Manual testing scenarios (*)

  1. Include CartPrice in Cart Graphql
  2. Also test all cart mutations

Questions or comments

  1. Similar GraphQl context check can be used in other areas to make the api's faster

@m2-assistant
Copy link

m2-assistant bot commented Oct 11, 2025

Hi @senthilengg. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@ct-prd-pr-scan
Copy link

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

@senthilengg
Copy link
Author

@magento run Unit Tests

@senthilengg
Copy link
Author

@magento run Unit Tests

@senthilengg
Copy link
Author

@magento run Database Compare,Functional Tests CE,Functional Tests EE,Functional Tests B2B,Integration Tests,Magento Health Index,Sample Data Tests CE,Sample Data Tests EE,Sample Data Tests B2B,Static Tests,WebAPI Tests,Semantic Version Checker

@senthilengg
Copy link
Author

@magento run Static Tests

@senthilengg
Copy link
Author

@magento run WebAPI Tests

Copy link
Author

@senthilengg senthilengg left a comment

Choose a reason for hiding this comment

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

Resolved conflicts and Copyright format updated.

@senthilengg
Copy link
Author

@magento run Unit Tests, Static Tests, WebAPI Tests

@senthilengg
Copy link
Author

@magento run Unit Tests, Static Tests, WebAPI Tests

@senthilengg
Copy link
Author

Based on my further review and IIRC gift wrapping price is not set as part of totals but part of quote. So the error seems to be not related. Please go ahead with the review.

@engcom-Hotel
Copy link
Contributor

@magento run all tests

@engcom-Hotel engcom-Hotel moved this from On Hold to Review in Progress in Community Dashboard Nov 3, 2025
Copy link
Contributor

@engcom-Hotel engcom-Hotel left a comment

Choose a reason for hiding this comment

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

Thank you @senthilengg for the fixes. Please refer to the below review comments.

@engcom-Hotel engcom-Hotel moved this from Review in Progress to Changes Requested in Community Dashboard Nov 3, 2025
@senthilengg
Copy link
Author

@magento run Unit Tests, Static Tests, WebAPI Tests

@engcom-Hotel
Copy link
Contributor

@magento run all tests

Copy link
Contributor

@engcom-Hotel engcom-Hotel left a comment

Choose a reason for hiding this comment

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

Hello @senthilengg,

It seems the WebAPI tests are failing due to this PR changes. Please fix those.

Thank you

@engcom-Hotel engcom-Hotel moved this from Review in Progress to Changes Requested in Community Dashboard Nov 4, 2025
@senthilengg
Copy link
Author

senthilengg commented Nov 4, 2025

@engcom-Hotel I couldn't guess what it could be, because its failing only for B2B & EE and not for open source. Is there a way to reproduce this issue without commerce testing license or let me know how to subscribe for EE/B2B sandbox license.

Also testGiftWrapping is not run for any of the previous builds for other PR, so I couldn't compare as well. So I am not sure how did you conclude its because of this PR.

@engcom-Hotel
Copy link
Contributor

Hello @senthilengg,

We will analyse the failures, and if they are determined to be related to B2B/EE, we will handle them internally.

Thank you

@senthilengg
Copy link
Author

senthilengg commented Nov 5, 2025

@engcom-Hotel

  1. The test script doesn't seems to be setting the address for the collectTotal to run
  2. trigger_recollect must be set to 1 or $quote->collectTotals() should be called after add product to cart

Something like the below

$addressData = include INTEGRATION_TESTS_DIR . '/testsuite/Magento/Sales/_files/address_data.php';

/** @var QuoteAddress $billingAddress */
$billingAddress = $objectManager->create(QuoteAddress::class, ['data' => $addressData]);
$billingAddress->setAddressType('billing');

$shippingAddress = clone $billingAddress;
$shippingAddress->setId(null)->setAddressType('shipping');

/**
 * @var QuoteResource $quote
 * @var Quote $quoteModel
 */
$quote = $objectManager->create(QuoteResource::class);
$quoteModel = $objectManager->create(Quote::class);
$quoteModel->setData(['store_id' => 1, 'is_active' => 1, 'is_multi_shipping' => 0, 'trigger_recollect' => 1]);
$quoteModel->setBillingAddress($billingAddress);
$quoteModel->setShippingAddress($shippingAddress);
$quote->save($quoteModel);

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

Labels

Priority: P3 May be fixed according to the position in the backlog. Progress: needs update Progress: on hold Project: Community Picked PRs upvoted by the community Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Projects

Status: Changes Requested

Development

Successfully merging this pull request may close these issues.

Cart Query >> CartPrice GraphQl Performance Optimisation

4 participants