Basket Controller addProduct doesn't work
Posted: 24 Oct 2016, 11:20
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é