Error when adding product to cart – Call to getUid() on null in ProductController (TYPO3 v13.4.15)
Hello, I'm working with TYPO3 v13.4.15 and using the extensions:
- extcode/cart
- extcode/cart-products
I followed the official tutorial to set everything up. However, when I try to add a product to the cart, I encounter the following error:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: Call to a member function getUid() on null Error thrown in file /var/www/html/vendor/extcode/cart-products/Classes/Controller/ProductController.php in line 327. Requested URL: https://website.ddev.site/produkte/detail.html?tx_cart_cart%5Baction%5D=add&tx_cart_cart%5Bcontroller%5D=Cart%5CProduct&cHash=31934542a2e732a8a848ed38907f060f
To make sure it's not project-specific, I tested the same setup in a different TYPO3 project — but the error still occurs in exactly the same way.
Steps to reproduce:
- Install TYPO3 v13.4.15
- Install and configure extcode/cart and extcode/cart-products using the tutorial
- Open the detail page of a product
- Try to add the product to the cart
Expected behavior:
The product should be added to the cart without errors.
Actual behavior:
A fatal error occurs when submitting the add-to-cart action. It seems like a null value is passed where an object is expected in ProductController.php on line 327.
Additional context:
Let me know if you need any further logs or configuration details. Thanks in advance!
I was able to fix the error — in my opinion, a TCA entry is missing!
In the database, it says: https://github.com/extcode/cart/blob/main/ext_tables.sql#L94 It's referenced here: https://github.com/extcode/cart/blob/main/Configuration/TCA/tx_cart_domain_model_order_tax.php#L21
But there is no TCA entry for it here: https://github.com/extcode/cart/blob/main/Configuration/TCA/tx_cart_domain_model_order_tax.php#L38-L65
Here's the code snippet that's missing in tx_cart_domain_model_order_tax.php:
],
'columns' => [
// --- HIER IST DIE FEHLENDE DEFINITION ---
// Diese Konfiguration für 'record_type' behebt den Fehler.
'record_type' => [
'exclude' => 0,
'label' => $_LLL . ':tx_cart_domain_model_order_tax.record_type',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
[$_LLL . ':tx_cart_domain_model_order_tax.record_type.tax', 'tax'],
[$_LLL . ':tx_cart_domain_model_order_tax.record_type.total_tax', 'total_tax'],
],
'default' => 'tax',
],
],
'tax' => [