Index: branches/5.2.x/core/kernel/db/cat_dbitem.php =================================================================== diff -u -N -r15608 -r16037 --- branches/5.2.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 15608) +++ branches/5.2.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 16037) @@ -1,6 +1,6 @@ Application->GetTempName($ci_table, 'prefix:' . $this->Prefix); } - // ensures, that CategoryId calculated field has primary category id in it - $keys_hash = Array ( - $this->IDField => $this->ID, - '`' . $ci_table . '`.`PrimaryCat`' => 1 - ); + if ( $this->Application->isAdmin ) { + // When coping new item from temp table, where no CategoryItems record present yet. + return parent::GetKeyClause($method, $keys_hash) . ' ORDER BY `' . $ci_table . '`.PrimaryCat DESC'; + } + else { + // Ensures, that CategoryId calculated field has primary category id in it. + $keys_hash = Array ( + $this->IDField => $this->ID, + '`' . $ci_table . '`.`PrimaryCat`' => 1 + ); + } } return parent::GetKeyClause($method, $keys_hash); } -} \ No newline at end of file +}