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

[FEATURE] Performance optimisation large shopping carts by preventing… #39290

Open
wants to merge 1 commit into
base: 2.4-develop
Choose a base branch
from

Conversation

lewisvoncken
Copy link
Contributor

@lewisvoncken lewisvoncken commented Oct 23, 2024

… call duplicate getActions

Description (*)

When you have for example 25 items in your shopping cart and 1 shopping cart rule the getActions is called 26 times but after this update it is called only once.

Manual testing scenarios (*)

  1. Create a Shopping Cart with multiple items
  2. Retrieve through GraphQL
curl --location 'https://example.com/graphql' \
--header 'store: nl_1' \
--header 'Content-Type: application/json' \
--data '{"query":"query getCartDetails($cartId: String!) {\n                  cart(cart_id: $cartId) {\n                      id\n                      ...CartMinimumFragment\n                  }\n              }\n              \n    fragment CartMinimumFragment on Cart {\n        id\n        total_quantity\n        is_virtual\n        email\n        ...PriceSummaryFragment\n        ...CartItemsFragment\n        ...AppliedCouponsFragment\n    }\n    \n    fragment PriceSummaryFragment on Cart {\n        items {\n            id\n            quantity\n        }\n        ...ShippingFragment\n        prices {\n            ...TaxSummaryFragment\n            ...DiscountSummaryFragment\n            ...GrandTotalFragment\n            subtotal_excluding_tax {\n                currency\n                value\n            }\n            subtotal_with_discount_excluding_tax {\n                currency\n                value\n            }\n            subtotal_including_tax {\n                currency\n                value\n            }\n        }\n    }\n    \n    fragment ShippingFragment on Cart {\n        shipping_addresses {\n            firstname\n            middlename\n            lastname\n            country {\n                code\n            }\n            street\n            city\n            region {\n                code\n            }\n            postcode\n            telephone\n            addressId: customer_address_id\n            selected_shipping_method {\n                carrier_code\n                carrier_title\n                method_code\n                method_title\n                amount {\n                    currency\n                    value\n                }\n            }\n            \n\n        }\n    }\n\n    \n    fragment GrandTotalFragment on CartPrices {\n        grand_total {\n            currency\n            value\n        }\n    }\n\n    \n    fragment TaxSummaryFragment on CartPrices {\n        applied_taxes {\n            amount {\n                currency\n                value\n            }\n            label\n        }\n    }\n\n    \n    fragment DiscountSummaryFragment on CartPrices {\n        discounts {\n            amount {\n                currency\n                value\n            }\n            label\n        }\n    }\n\n\n    \n    fragment CartItemsFragment on Cart {\n        items {\n            id\n            uid\n            errors {\n                code\n                message\n            }\n            product {\n                id\n                name\n                url_key\n                url_suffix\n                sku\n                type_id\n                stock_status\n                product_labels {\n                    code\n                    color\n                    image\n                    label\n                }\n                small_image {\n                    url\n                    label\n                }\n                categories {\n                    name\n                }\n                price {\n                    regularPrice {\n                        amount {\n                            currency\n                            value\n                        }\n                    }\n                }\n                price_tiers {\n                    quantity\n                    final_price {\n                        currency\n                        value\n                        __typename\n                    }\n                    discount {\n                        percent_off\n                        __typename\n                    }\n                    __typename\n                }\n                price_range {\n                    minimum_price {\n                        regular_price {\n                            value\n                            currency\n                        }\n                        final_price {\n                            currency\n                            value\n                        }\n                    }\n                }\n            }\n            prices {\n                price {\n                    currency\n                    value\n                }\n                row_total_including_tax {\n                    currency\n                    value\n                }\n            }\n            quantity\n            ... on ConfigurableCartItem {\n                id\n                options: configurable_options {\n                    id\n                    option_label\n                    value_id\n                    value_label\n                }\n            }\n            ... on GiftCardCartItem {\n                sender_name\n                sender_email\n                recipient_name\n                recipient_email\n                amount {\n                    currency\n                    value\n                }\n                message\n            }\n            ... on BundleCartItem {\n                id\n                bundle_options {\n                    id\n                    label\n                    type\n                    values {\n                        id\n                        label\n                        price\n                        quantity\n                    }\n                }\n            }\n        }\n    }\n\n    \n    fragment AppliedCouponsFragment on Cart {\n        applied_coupons {\n            code\n        }\n    }","variables":{"cartId":"XXXXXXX"}}'

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] [FEATURE] Performance optimisation large shopping carts by preventing… #39292: [FEATURE] Performance optimisation large shopping carts by preventing…

Copy link

m2-assistant bot commented Oct 23, 2024

Hi @lewisvoncken. 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.

@m2-github-services m2-github-services added Partner: Experius partners-contribution Pull Request is created by Magento Partner labels Oct 23, 2024
@engcom-Hotel engcom-Hotel added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Oct 23, 2024
@engcom-Hotel
Copy link
Contributor

@magento create issue

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Oct 23, 2024
@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

Hi @lewisvoncken,

Thanks for the collaboration & contribution!

✔️ QA Passed
Preconditions:

  • Install fresh Magento 2.4-develop

Steps to reproduce

  • As per the PR description

Before: ✖️
The $rule->getActions() method was being called multiple times for each item, even though the result was the same for a given rule.

After: ✔️
The $rule->getActions() method is now called only once per rule, by moving the call to the outer loop. This reduces redundant calls and improves performance.

Builds are failed. Hence, moving this PR to Extended Testing.

Thanks

@engcom-Dash
Copy link
Contributor

@magento run Static Tests, Integration Tests, Functional Tests EE, Functional Tests CE, Functional Tests B2B

@engcom-Dash
Copy link
Contributor

Hello @lewisvoncken,

Thanks for the contributions!

It seems that we don't have permission to commit fixes to the repository. Could you please fix the static failure related to copyright tag?

To fix it, replace the following copyright tag::

 /**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

With this one:

Copyright [year file created] Adobe 
All Rights Reserved.

See sample commit here.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Partner: Experius partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for testing Project: Community Picked PRs upvoted by the community Risk: low Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Status: Extended testing (optional)
Development

Successfully merging this pull request may close these issues.

[Issue] [FEATURE] Performance optimisation large shopping carts by preventing…
6 participants