Index: kernel/db/cat_dbitem.php =================================================================== --- kernel/db/cat_dbitem.php (revision 15541) +++ kernel/db/cat_dbitem.php (working copy) @@ -601,26 +601,21 @@ */ protected function GetKeyClause($method = null, $keys_hash = null) { - if ($method == 'load') { + if ( $method == 'load' && !isset($keys_hash) ) { // for item with many categories makes primary to load $ci_table = TABLE_PREFIX . 'CategoryItems'; - if ($this->IsTempTable()) { + if ( $this->IsTempTable() ) { $ci_table = $this->Application->GetTempName($ci_table, 'prefix:' . $this->Prefix); } - $primary_category_clause = Array ('`' . $ci_table . '`.`PrimaryCat`' => 1); - - if (!isset($keys_hash)) { - $keys_hash = Array ($this->IDField => $this->ID); - } - - // merge primary category clause in any case to be sure, that - // CategoryId field will always contain primary category of item - $keys_hash = array_merge($keys_hash, $primary_category_clause); + // 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