Closed ryanmitchell closed 1 year ago
We should only save sortField (and sortDirection) if it's a custom value.
By leaving it blank, it'll apply the appropriate logic.
The custom value would be in the property. We could probably add a method to the Collection class like customSortField
and then change this line to 'sort_field' => $source->customSortField()
.
In order for this fix to be reflected, you'll need get rid of the custom sort field and direction.
You can run php artisan tinker
and run this for each collection, substituting the collection handle appropriately.
\Statamic\Eloquent\Collections\CollectionModel::where('handle', 'your_collection')->update([
'settings->sort_field' => null,
'settings->sort_dir' => null,
]);
Or, put it in a migration.
@robdekort found a lovely bug that when you have a dated collection and make it order able it wasn't honouring the order you set. So this fix changes it by not saving the
sortField
to the database when the collection is orderable.