Skip to content

Instantly share code, notes, and snippets.

@MrMooky
Last active November 18, 2021 12:05
Show Gist options
  • Save MrMooky/fc1fad5a47f2942e4c8c6208a66c99f0 to your computer and use it in GitHub Desktop.
Save MrMooky/fc1fad5a47f2942e4c8c6208a66c99f0 to your computer and use it in GitHub Desktop.
public function findSimilarInCategories($categories, $ignore_id)
{
$query = $this->createQuery();
// $catUids = [];
// foreach ($categories as $category) {
// $catUids[] = $category->getUid();
// }
// \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($catUids);
$query->matching(
$query->logicalNot(
$query->equals('uid', $ignore_id)
),
$query->logicalOr(
$query->in('categories', $categories)
)
);
return $query->setLimit(12)->execute();
}
@mkrappitz
Copy link

Ich würde das draus machen:

    $query->matching(
        $query->logicalAnd(
            $query->logicalNot(
                $query->equals('uid', $ignore_id)
            ),
            $query->in('categories.uid', $categories)
        )
    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment