diff --git a/model/class.tx_ttproducts_article.php b/model/class.tx_ttproducts_article.php index 0573796c2..3d81b477a 100644 --- a/model/class.tx_ttproducts_article.php +++ b/model/class.tx_ttproducts_article.php @@ -66,7 +66,10 @@ public function init($functablename): bool $tableObj = $this->getTableObj(); $tableObj->setConfig($tableConfig); - $tableObj->addDefaultFieldArray(['sorting' => 'sorting']); + + if (isset($GLOBALS['TCA'][$tableObj->getName()]['columns']['sorting'])) { + $tableObj->addDefaultFieldArray(['sorting' => 'sorting']); + } } return $result; diff --git a/model/class.tx_ttproducts_category.php b/model/class.tx_ttproducts_category.php index eb932af9b..eff8596dd 100644 --- a/model/class.tx_ttproducts_category.php +++ b/model/class.tx_ttproducts_category.php @@ -62,7 +62,9 @@ public function init( $cnf = GeneralUtility::makeInstance('tx_ttproducts_config'); $this->tableconf = $cnf->getTableConf($functablename); $tableObj = $this->getTableObj(); - $tableObj->addDefaultFieldArray(['sorting' => 'sorting']); + if (isset($GLOBALS['TCA'][$tableObj->getName()]['columns']['sorting'])) { + $tableObj->addDefaultFieldArray(['sorting' => 'sorting']); + } $tablename = $this->getTablename(); $tableObj->setTCAFieldArray($tablename); diff --git a/model/class.tx_ttproducts_email.php b/model/class.tx_ttproducts_email.php index 2b8c564f3..d7c1c4ac0 100644 --- a/model/class.tx_ttproducts_email.php +++ b/model/class.tx_ttproducts_email.php @@ -52,9 +52,12 @@ public function init($functablename): bool $result = parent::init($functablename); if ($result) { + $tableObj = $this->getTableObj(); $tablename = $this->getTablename(); - $this->getTableObj()->addDefaultFieldArray(['sorting' => 'sorting']); - $this->getTableObj()->setTCAFieldArray('tt_products_emails'); + if (isset($GLOBALS['TCA'][$tablename]['columns']['sorting'])) { + $tableObj->addDefaultFieldArray(['sorting' => 'sorting']); + } + $tableObj->setTCAFieldArray('tt_products_emails'); } return $result; diff --git a/model/class.tx_ttproducts_product.php b/model/class.tx_ttproducts_product.php index cde566648..2a133a41d 100644 --- a/model/class.tx_ttproducts_product.php +++ b/model/class.tx_ttproducts_product.php @@ -82,7 +82,9 @@ public function init( $tableObj = $this->getTableObj(); $tableObj->setConfig($tableConfig); - $tableObj->addDefaultFieldArray(['sorting' => 'sorting']); + if (isset($GLOBALS['TCA'][$tableObj->getName()]['columns']['sorting'])) { + $tableObj->addDefaultFieldArray(['sorting' => 'sorting']); + } } return $result; diff --git a/view/class.tx_ttproducts_list_view.php b/view/class.tx_ttproducts_list_view.php index e77f87d42..e8b492dd0 100644 --- a/view/class.tx_ttproducts_list_view.php +++ b/view/class.tx_ttproducts_list_view.php @@ -1375,6 +1375,12 @@ public function printView( ksort($displayConf['header'], SORT_STRING); } } + + $categorySorting = 'uid'; + if (isset($GLOBALS['TCA'][$categoryTable->getTableObj()->getName()]['columns']['sorting'])) { + $categorySorting = 'sorting'; + } + $selectConf['orderBy'] = $tableConfArray[$functablename]['orderBy']; // performing query for display: if (!$selectConf['orderBy']) { @@ -2018,8 +2024,7 @@ public function printView( ) { $currentCat = $row['category']; } - - $catArray = $categoryTable->getCategoryArray($row, 'sorting'); + $catArray = $categoryTable->getCategoryArray($row, $categorySorting); if ( empty($tableConfArray[$categoryfunctablename]['onlyDefaultCategory']) && diff --git a/view/class.tx_ttproducts_single_view.php b/view/class.tx_ttproducts_single_view.php index 186a21db8..f89b3374b 100644 --- a/view/class.tx_ttproducts_single_view.php +++ b/view/class.tx_ttproducts_single_view.php @@ -1097,6 +1097,13 @@ public function printView( ); $count = count($orderByFieldArray); + if ( + !isset($GLOBALS['TCA'][$tablename]['columns']['sorting']) && + in_array('sorting', $orderByFieldArray) + ) { + throw new RuntimeException('Error in tt_products: No "sorting" field is set in the backend for table "' . $tablename . '", but it is set in the setup of orderBy.', 1708024007); + } + if ($count) { $bDefaultOrder = false; $queryPrevPrefixArray = [];