diff --git a/models/Category.php b/models/Category.php index 4e1834351..984698611 100644 --- a/models/Category.php +++ b/models/Category.php @@ -4,6 +4,7 @@ namespace OFFLINE\Mall\Models; +use Cache; use DB; use Illuminate\Support\Facades\Queue; use Model; @@ -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; @@ -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; @@ -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); + }); + } } diff --git a/updates/version.yaml b/updates/version.yaml index ab0097653..e5c1ef6a8 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -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'