Skip to content

Commit

Permalink
Merge branch 'release/4.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
nfourtythree committed Jan 12, 2024
2 parents 27ca37d + dc06176 commit ad0ad0b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes for Craft Commerce

## 4.4.1 - 2024-01-12

- Fixed a SQL error that could occur when updating to Commerce 4.4.0 on MySQL. ([#3367](https://github.com/craftcms/commerce/issues/3367))
- Fixed a PHP error that occurred when saving a discount. ([#3364](https://github.com/craftcms/commerce/issues/3364))

## 4.4.0 - 2024-01-11

- Craft Commerce now requires Craft CMS 4.6.0 or later.
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/DiscountsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function actionSave(): ?Response
$discount->perEmailLimit = (int)$this->request->getBodyParam('perEmailLimit');
$discount->totalDiscountUseLimit = (int)$this->request->getBodyParam('totalDiscountUseLimit');
$discount->ignoreSales = (bool)$this->request->getBodyParam('ignoreSales');
$discount->categoryRelationshipType = $this->request->getBodyParam('categoryRelationshipType');
$discount->categoryRelationshipType = $this->request->getBodyParam('categoryRelationshipType', $discount->categoryRelationshipType);
$discount->baseDiscountType = $this->request->getBodyParam('baseDiscountType') ?: DiscountRecord::BASE_DISCOUNT_TYPE_VALUE;
$discount->appliedTo = $this->request->getBodyParam('appliedTo') ?: DiscountRecord::APPLIED_TO_MATCHING_LINE_ITEMS;
$discount->orderConditionFormula = $this->request->getBodyParam('orderConditionFormula');
Expand Down
8 changes: 6 additions & 2 deletions src/services/Discounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,12 @@ public function ensureSortOrder(): void
} else {
$sql = <<<SQL
UPDATE $table a
JOIN (SELECT id, [[sortOrder]], ROW_NUMBER() OVER (ORDER BY [[sortOrder]] ASC, id ASC) as rownumber
FROM $table) b ON a.id = b.id
JOIN (
SELECT id, [[sortOrder]], (@ROW_NUMBER := @ROW_NUMBER + 1) as rownumber
FROM $table,
(SELECT @ROW_NUMBER := 0) AS X
ORDER BY [[sortOrder]] ASC, id ASC
) b ON a.id = b.id
SET [[a.sortOrder]] = b.rownumber
SQL;
}
Expand Down

0 comments on commit ad0ad0b

Please sign in to comment.