Skip to content

Potential performance issue on loading shipping methods #40153

@Thirumalbalu

Description

@Thirumalbalu

Preconditions and environment

  • Magento version - 2.4.4 and upto 2.4.9-alpha2

Steps to reproduce

https://github.com/magento/magento2/blob/2.4.8/app/code/Magento/Shipping/Model/Config/Source/Allmethods.php#L45

Calling toOptionArray($isActiveOnlyFlag = false) with argument true still loads the Factories of all Shipping methods which consume unnecessary load time.

Following code loads the factory of all shipping methods:
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Shipping/Model/Config.php#L95

Expected result

Calling toOptionArray($isActiveOnlyFlag = false) with argument true should only load the factories of active shipping methods.

Actual result

Calling toOptionArray($isActiveOnlyFlag = false) with argument true loads the Factories of all Shipping methods.

Additional information

The issue can be fixed by introducing the conditional check on toOptionArray function like the below:

        if ($isActiveOnlyFlag) {
            $carriers = $this->_shippingConfig->getActiveCarriers();
        } else {
            $carriers = $this->_shippingConfig->getAllCarriers();
        }

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: ShippingComponent: ShippingIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Reported on 2.4.9-alpha2Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions