Search code examples
typo3cartfluid

TYPO3 EXT:cart_product: extend backend with one selection to do conditional theming in template


I'm looking for a way to extend the backend of the TYPO3 extension cart_products with one additional select field. I have already created some different ViewHelpers for the ProductBackendVariants and now need a way to choose the corresponding Viewhelper.

Best would be if there is a selection direct after the type select in the general product type. But I am not able to add some additional configuration fields to this tab.

Already added

'formtemplate' => [   
    'label' => 'ProductDetail Variant Form',
    'config' => [
        'type' => 'select',
        'renderType' => 'selectSingle',
        'items' => [
            ['Standard', 1],
            ['Matten', 2],
            ['Zaunpaket', 3],
        ],
        'size' => 1,
        'minitems' => 1,
        'maxitems' => 1,
    ],
],

to the tx_cartproducts_domain_model_product_product.php but nothing appears in the backend.


Solution

  • I don't know that specific extension but some hints in general:

    • it seems that you have tried to modified the TCA directly in the extension (cart_products/Configuration/TCA/tx_cartproducts_domain_model_product_product.php). You should never change anything in a 3rd party extension (neither the TYPO3 core) because you loose the ability to update.
    • You need to create your own extension and add a file to Configuration/TCA/Overrides. Ideally you name the file exactly like the file you like to extend for easier understanding. See the documentation for details.
    • To add a new field to the TCA you not only need to define the name and type but you also need to create the database field. That's done in ext_tables.sql of your custom extension.
    • It's not sufficent to create the TCA config and SQL mentioned above you also need to tell, where the new field should be visible in the backend. That's done with the showitem setting. See documentation for details.
    • To ease the process of extending an existing TCA I can recommend the extension TCA Builder which makes it in many cases much easier to create the TCA code. See these examples how that's done. Nevertheless you need to create ext_tables.sql.
    • Last but not least: when you made changes to ext_tables.sql you need to run the database compare in the TYPO3 install tool.