Sort order save in _Live table

This commit is contained in:
Amol Wankhede 2019-05-10 17:52:03 +12:00
parent b6f03225d0
commit 2eb6213c79
1 changed files with 9 additions and 2 deletions

View File

@ -463,6 +463,9 @@ class GridFieldOrderableRows extends RequestHandler implements
if ($class == $this->getSortTable($list)) {
$isVersioned = $class::has_extension('Versioned');
}
if ($class::has_extension('Versioned')) {
$isVersioned = true;
}
// Loop through each item, and update the sort values which do not
// match to order the objects.
@ -505,11 +508,15 @@ class GridFieldOrderableRows extends RequestHandler implements
// similar to the SiteTree where you change the position, and then
// you go into the record and publish it.
foreach($sortedIDs as $sortValue => $id) {
if($map[$id] != $sortValue) {
$record = $class::get()->byID($id);
$record = $class::get()->byID($id);
if ($map[$id] != $sortValue) {
$record->$sortField = $sortValue;
$record->write();
}
// Update stage to live only for published records
if ($record->isPublished()) {
$record->publish('Stage', 'Live');
}
}
}