Skip to content

Commit

Permalink
Fixed manual sort orders in categories
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-kuendig committed Dec 12, 2024
1 parent ad3433e commit 855aeaf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace OFFLINE\Mall\Models;

use Cache;
use DB;
use Illuminate\Support\Facades\Queue;
use Model;
Expand All @@ -12,7 +13,9 @@
use October\Rain\Database\Traits\SortableRelation;
use October\Rain\Database\Traits\Validation;
use October\Rain\Support\Collection;
use OFFLINE\Mall\Classes\Index\Index;
use OFFLINE\Mall\Classes\Jobs\PropertyRemovalUpdate;
use OFFLINE\Mall\Classes\Observers\ProductObserver;
use OFFLINE\Mall\Classes\Traits\Category\MenuItems;
use OFFLINE\Mall\Classes\Traits\Category\Properties;
use OFFLINE\Mall\Classes\Traits\Category\Slug;
Expand All @@ -24,7 +27,9 @@ class Category extends Model
use Validation;
use SoftDelete;
use NestedTree;
use SortableRelation;
use SortableRelation {
setSortableRelationOrder as traitSetSortableRelationOrder;
}
use MenuItems;
use Slug;
use Translation;
Expand Down Expand Up @@ -319,4 +324,13 @@ public function getInheritedReviewCategories()

return $groups ?? new Collection();
}

public function setSortableRelationOrder($relationName, $itemIds, $referencePool = null) {
$this->traitSetSortableRelationOrder($relationName, $itemIds, $referencePool);

$this->products->each(function (Product $product) {
Cache::forget(Product::sortOrderCacheKey($product->id));
(new ProductObserver(app(Index::class)))->updated($product);
});
}
}
2 changes: 2 additions & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,5 @@ v3.5.13:
- 'Fixed RainLab.User v3 compatibility'
v3.5.14:
- 'Support for more flexible model extensions in the backend (thanks to @xyz1123581321)'
v3.5.15:
- 'Fixed category-specific manual sort orders'

0 comments on commit 855aeaf

Please sign in to comment.