Basket Controller addProduct doesn't work
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Basket Controller addProduct doesn't work
Hello!
I'm having trouble while adding a product to the basket via the built-in basket controller.
The code is as follows:
$felsoid is a product ID in string format, exactly as specified in the docs and the comments preceding the function, yet I'm getting the following error:
ErrorException in Base.php line 163: Argument 1 passed to Aimeos\MShop\Order\Item\Base\Base::addProduct() must be an instance of Aimeos\MShop\Order\Item\Base\Product\Iface, string given, called in MYPATH\Modules\Setgenerator\Http\Controllers\SetgeneratorController.php on line 39 and defined MYPATH\vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Order\Item\Base\Base.php
Unless I'm really missing something, it seems somewhere down the line aimeos doesn't request the proper object, but hands down the string ID when trying to create the Order object proper.
Thank you for your reply in advance,
Máté
I'm having trouble while adding a product to the basket via the built-in basket controller.
The code is as follows:
Code: Select all
$context = app( '\Aimeos\Shop\Base\Context' )->get();
$basket = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' )->get();
$basket->addProduct($felsoid, 1);
ErrorException in Base.php line 163: Argument 1 passed to Aimeos\MShop\Order\Item\Base\Base::addProduct() must be an instance of Aimeos\MShop\Order\Item\Base\Product\Iface, string given, called in MYPATH\Modules\Setgenerator\Http\Controllers\SetgeneratorController.php on line 39 and defined MYPATH\vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Order\Item\Base\Base.php
Unless I'm really missing something, it seems somewhere down the line aimeos doesn't request the proper object, but hands down the string ID when trying to create the Order object proper.
Thank you for your reply in advance,
Máté
Re: Basket Controller addProduct doesn't work
You are using the addProduct() for the \Aimeos\MShop\Order\Item\Base\Iface which requires and object instead of the addProduct() method of the \Aimeos\Controller\Frontend\Basket\Iface due to the "->get()" call.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Basket Controller addProduct doesn't work
Thanks! That solved that problem, though now I have like 99 other ones