The product with ID "xy" may not be added directly to the shopping cart

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
rvhelp2
Posts: 29
Joined: 29 Oct 2022, 10:10

The product with ID "xy" may not be added directly to the shopping cart

Post by rvhelp2 » 09 Nov 2022, 17:14

Hello, after updating to 21.4.4 we have the problem that products without variants can no longer be added to the cart. Do you know what could be the reason for this?

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: The product with ID "xy" may not be added directly to the shopping cart

Post by aimeos » 10 Nov 2022, 06:53

2021.04.x/21.4.x isn't supported any more and also 2021.10.x/21.10.x LTS will be out of regular support in the near future so you should upgrade to 2022.10.x/22.10.x LTS instead.

Check if the stock values are still associated to the products because referencing them changed from product code to product ID.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

rvhelp2
Posts: 29
Joined: 29 Oct 2022, 10:10

Re: The product with ID "xy" may not be added directly to the shopping cart

Post by rvhelp2 » 10 Nov 2022, 07:57

Sorry, I meant 22.4.4.

$product->getListItems( 'catalog' ) is empty ->
for some reason there is no ["catalog"] part in the $product

$prodIds is empty too

Code: Select all

public function addProduct( \Aimeos\MShop\Product\Item\Iface $product, float $quantity = 1,
		array $variant = [], array $config = [], array $custom = [], string $stocktype = 'default'
	) : \Aimeos\Controller\Frontend\Basket\Iface
	{
		if( $product->getListItems( 'catalog' )->isEmpty() )
		{
			$context = $this->context();
			$manager = \Aimeos\MShop::create( $context, 'product' );

			$filter = $manager->filter(true);
			$func = $filter->make( 'product:has', ['product', 'default', $product->getId()] );

			$filter->add( $filter->is( $func, '!=', null ) );

			$prodIds = $manager->search( $filter )->keys()->all();

			if( empty( $prodIds ) || !$this->checkCategory( $prodIds ) )
			{
				$msg = $context->translate( 'controller/frontend', 'Adding product with ID "%1$s" is not allowed' );
				throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $product->getId() ) );
			}
		}

		$this->getController()->addProduct( $product, $quantity, $variant, $config, $custom, $stocktype );

		return $this;
	}

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: The product with ID "xy" may not be added directly to the shopping cart

Post by aimeos » 11 Nov 2022, 06:00

2022.04.x/22.4.x is also not supported any more, just 2022.10/22.10 LTS.

Does the products have at least one category assigned?
From where do you try to add the product? Catalog list or detail view?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

rvhelp2
Posts: 29
Joined: 29 Oct 2022, 10:10

Re: The product with ID "xy" may not be added directly to the shopping cart

Post by rvhelp2 » 17 Nov 2022, 08:50

Yes, but at the time we cannot update to 2022.10 because than the statistic is missing orders (viewtopic.php?f=15&t=4847&p=18974&hilit ... ies#p18974).

The Porducts have at least one category assigned. I tried to add the product in the detail view.

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: The product with ID "xy" may not be added directly to the shopping cart

Post by aimeos » 17 Nov 2022, 18:25

rvhelp2 wrote: 17 Nov 2022, 08:50 Yes, but at the time we cannot update to 2022.10 because than the statistic is missing orders (viewtopic.php?f=15&t=4847&p=18974&hilit ... ies#p18974).
It would be better to provide more details for that problem first and then update to 2022.10 as the other problem might be solved automatically.
rvhelp2 wrote: 17 Nov 2022, 08:50 The Porducts have at least one category assigned. I tried to add the product in the detail view.
Doesn't it only work for some products or all products? Did it work before?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

rvhelp2
Posts: 29
Joined: 29 Oct 2022, 10:10

Re: The product with ID "xy" may not be added directly to the shopping cart

Post by rvhelp2 » 18 Nov 2022, 09:41

For Article that are not variants. It worked before yes, but not with this version.

Post Reply