Skip to content
Snippets Groups Projects
Commit a2477dbc authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Fixing a bug with matching the tags when migrating news

parent a2ba24c7
No related branches found
No related tags found
No related merge requests found
......@@ -174,11 +174,7 @@ class MigrateNewsCommandController extends CommandController {
$date = new \DateTime('@' . $row['datetime']);
$newsPage->setLastUpdated($date);
$matchingTag = $this->getMatchingTag($row);
if ($matchingTag && $matchingTag instanceof Tag) {
$newsPage->addTag($matchingTag);
}
$this->setMatchingTag($row);
/** @var File $image */
$file = $this->getMatchingFile($row);
......@@ -253,17 +249,26 @@ class MigrateNewsCommandController extends CommandController {
* Get the tag / category, matching the news
*
* @param array $row
* @return Object $tag
*/
private function getMatchingTag(array $row) {
// look up the correct category id, if they have changed
if (isset($this->categoryMap[(int) $row['categories']])) {
$categoryId = $this->categoryMap[(int) $row['categories']];
} else {
$categoryId = (int) $row['categories'];
}
private function setMatchingTag(array $row) {
/** @var DatabaseConnection $db */
$db = $GLOBALS['TYPO3_DB'];
// get content element from the original page
$where = 'uid_foreign = ' . (int) $row['uid'];
/** @var \mysqli_result $result */
$result = $db->exec_SELECTquery('uid_local', 'sys_category_record_mm_news_migration', $where);
return $this->tagRepository->findByUid($categoryId);
foreach ($result->fetch_row() as $mmRow) {
$values = [
'uid_local' => $this->categoryMap[(int) $mmRow[0]],
'uid_foreign' => $this->newsPagesMap[(int) $row['uid']],
'tablenames' => 'pages',
'fieldname' => 'tx_sgnews_tags'
];
$db->exec_INSERTquery('sys_category_record_mm', $values);
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment