Sorting Multisite Tailor Models and reseting order

Hi, usually when I get some error on the reordering of models, I fix it using the following:

(new ModelClass)->resetTreeNesting();

or in the case of Tailor:

(new EntryRecord)::inSection('blueprinthandle')->resetTreeNesting();

The problem is that (at least in the case of Tailor) when the model has multisite activated, this fix only works for the main language/site. The ordering error persists in the remaining sites/languages. So this brings me to two questions:

  1. How could I fix this for all the sites/languages?
  2. How to make sorting order propagatable to all sites/languages?

Try using Site::withContext($siteId, (...));

Site::withContext($siteId, function() {
    (new EntryRecord)::inSection('blueprinthandle')->resetTreeNesting();
1 Like

Hey @daft it worked, though I guess it is withContext() and not inContext().
Also, I’m curious about my question number 2:
How to make sorting order propagatable to all sites/languages? Both in Tailor and regular models (though I guess the logic would be quite similar). Can we make the sort_order field propagatable? Is that the way?

Yes, this is a known issue, and records may require manual sorting across sites for the time being.

Ups. this issue in fact might be big in some scenarios where lots of records and several sites. So the propagatable sort_option woudn´t work?

I guess this sorting across sites and also the option to have latest records first by default on sorted records (and not last) are important and nice to have features.