cart icon indicating copy to clipboard operation
cart copied to clipboard

Error handling of deactivated products

Open paul-keller opened this issue 7 years ago • 2 comments

Trying to call a deactivated product in the frontend results in an TYPO3 Error. This should show a message like "product not found" or then be a redirect to the configuered error404 page.

Try: https://www.weingut-isele.de/weine/detail/weinsortiment/testwein/ If a link to a product is communicated in a newsletter for example and suddenly the product is out of stock and deactivated for that reason, the user gets an TYPO3 Error...

paul-keller avatar Mar 28 '18 02:03 paul-keller

TYPO3 v12 has a solution for this as far as I understand it: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Routing/AdvancedRoutingConfiguration.html#aspect-fallback-value-handling

I will have a look at it later and add possible solutions to the docs.

rintisch avatar Jun 03 '24 13:06 rintisch

@paul-keller The issue itself is not really related to EXT:cart but to of the used product extension.

I realized that the problem is already solved in EXT:cart_products 5.x-dev:

    public function showAction(Product $product = null): ResponseInterface
    {
        if (!$product) {
            $product = $this->getProduct();
        }
        if (!$product) {
            return new ForwardResponse('list');
        }

(see source)

So if the product does no longer exists the list view will be used. This is not optimal as the URL stays the same. But you can of course adapt this behaviour in your own extension with e.g.

return $this->redirect(actionName: 'list', pageUid: <the PID of the fitting list view>);

To implement this in EXT:cart_products would also be possible if we would add a listViewPID to the flexform of the show plugin. If it's set we could use this variable to redirect to the list properly...

rintisch avatar Jun 03 '24 15:06 rintisch