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

Prevent unnecessary Order objects from being created in Admin Orders #11235

merged 2 commits into from Nov 20, 2018


None yet
4 participants

mnastalski commented Nov 2, 2018

Questions Answers
Branch? develop
Description? Every order loaded into the backend's order list creates a new Order object to retrieve its' id_currency. This results in n+1 queries being executed (with 50 orders that's 50 extra queries). This PR aims to remove that behavior, by using $tr's id_currency value instead.
Type? improvement / refacto
Category? BO
BC breaks? no
Deprecations? no
Fixed ticket? -
How to test? Open the orders list in backend office.

This change is Reviewable


Nice idea, I would however suggest a change to prevent compatibility issues wth modules which could use this method:

    public static function setOrderCurrency($echo, $tr)
        if (!empty($tr['id_currency'])) {
            $idCurrency = (int) $tr['id_currency'];
        } else {
            $order = new Order($tr['id_order']);
            $idCurrency = (int) $order->id_currency;

        return Tools::displayPrice($echo, $idCurrency);

By doing this, we add your performance improvement, but keep the backward compatibility with modules which only send the order id.


This comment has been minimized.


mnastalski commented Nov 19, 2018

@Quetzacoalt91 Sounds great, updated

@Quetzacoalt91 Quetzacoalt91 added this to the milestone Nov 20, 2018

@marionf marionf added QA ✔️ and removed waiting for QA labels Nov 20, 2018

@Quetzacoalt91 Quetzacoalt91 merged commit 37eb002 into PrestaShop:develop Nov 20, 2018

2 checks passed

Codacy/PR Quality Review Up to standards. A positive pull request.
continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.


Quetzacoalt91 commented Nov 20, 2018

Thank you @mnastalski

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