Search code examples
typo3bidirectionaltypo3-tca

TYPO3 Extbase: bidirectional relation on same table


I would like to set up a bidirectional connection on a product table.
To create related products.

'related_products' => [
    'exclude' => 1,
    'label'   => 'Varianten',
    'config'  => [
        'type'                => 'select',
        'renderType'          => 'selectSingle',
        'renderType'          => 'selectMultipleSideBySide',
        'foreign_table'       => 'tx_ppcatalog_domain_model_product',
        'MM'                  => 'tx_ppcatalog_product_related_product_mm',
        'MM_opposite_fiel'    => 'related_products',
    ],
],

But the relation is only stored in one direction. Is this possible at all? And if so can you also include the translations here?


Solution

  • I don't think it's not possible to set the MM_opposite_field (which is missing a 'd' in your code block) to the same field as the local field. You'd have to add a separate field. Here's an example how the news extension does it: https://github.com/georgringer/news/blob/master/Configuration/TCA/tx_news_domain_model_news.php#L310