Skip to content

Commit

Permalink
Fixed #3481 store query performance
Browse files Browse the repository at this point in the history
  • Loading branch information
nfourtythree committed May 22, 2024
1 parent 3947b68 commit 3815a75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Improved store query performance. ([#3481](https://github.com/craftcms/commerce/issues/3481))
- Fixed a bug where the store management menu was not listing all items on the Stores index page.
- Fixed an SQL error that occurred when using the `hasStock` Purchasable query param. ([#3505](https://github.com/craftcms/commerce/issues/3505))
- Fixed an error that could occur when querying products via GraphQL.
Expand Down
7 changes: 3 additions & 4 deletions src/services/Stores.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,9 @@ private function _createStoreQuery(): Query

// Added to avoid migration issues, as settings were moved after stores table creation
// @TODO remove at next breaking change release
$projectConfig = Craft::$app->getProjectConfig();
$schemaVersion = $projectConfig->get('plugins.commerce.schemaVersion', true);
$commerce = Craft::$app->getPlugins()->getStoredPluginInfo('commerce');

if (version_compare($schemaVersion, '5.0.72', '>=')) {
if (version_compare($commerce['schemaVersion'], '5.0.72', '>=')) {
$selectColumns = array_merge($selectColumns, [
'allowCheckoutWithoutPayment',
'allowEmptyCartOnCheckout',
Expand All @@ -620,7 +619,7 @@ private function _createStoreQuery(): Query
->select($selectColumns)
->from([Table::STORES]);

if (version_compare($schemaVersion, '5.0.72', '>=')) {
if (version_compare($commerce['schemaVersion'], '5.0.72', '>=')) {
$query->orderBy(['sortOrder' => SORT_ASC]);
}

Expand Down

0 comments on commit 3815a75

Please sign in to comment.