Skip to content

Conversation

@rostyslav-hymon
Copy link
Contributor

Original Pull Request

#12893
Dear Magento2,

This PR consists of several improvements and bug fixes. The main goal of it is to increase performance and logic side of the Magento\Sales\Helper\Guest. Please, review Description section for more information.

Looking forward to your reply,
Alex

Description

The main improvements here are in the Magento\Sales\Helper\Guest::getOrderRecord($incrementId)

  1. Added store_id as filter to search criteria to improve logic/performance and due to this fact the Magento\Sales\Helper\Guest::validateOrderStoreId($orderStoreId) can be removed.

  2. Replaced

        if ($records->getTotalCount() < 1) {
            throw new InputException(__($this->inputExceptionMessage));
        }
        $items = $records->getItems();
        return array_shift($items);

with

        $items = $records->getItems();
        if (empty($items)) {
            throw new InputException(__($this->inputExceptionMessage));
        }

        return array_shift($items);

This allows Magento to reduce the number of database queries because every time when the getTotalCount() is called it initiates the getSize() method which checks the $this->_totalRecords value but in this case it equals to null every new call because every new call begins after page load.

  1. Moved $this->hasPostDataEmptyFields($post) to ternary operator because this is good to have all conditions according to order in one place.

  2. Fixed typo compareSoredBillingDataWithInput to compareStoredBillingDataWithInput

  3. Removed underscore private $_storeManager; to private $storeManager; (PSR-2: Property names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility.)

Fixed Issues (if relevant)

No relevant issue.

Manual testing scenarios

Those changes didn't change business logic. Only code improvement and, as a result, no manual testing scenarios.

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)
  • All automated tests passed successfully (all builds on Travis CI are green)

@orlangur orlangur self-assigned this Mar 26, 2018
@magento-engcom-team
Copy link
Contributor

Hi @orlangur, thank you for the review.
ENGCOM-1085 has been created to process this Pull Request

@magento-engcom-team magento-engcom-team merged commit 8232732 into magento:2.3-develop Mar 26, 2018
magento-engcom-team pushed a commit that referenced this pull request Mar 26, 2018
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.

4 participants