Error throwing exception in Plugin ProductLimit

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
edu27
Posts: 9
Joined: 04 Mar 2020, 19:40

Error throwing exception in Plugin ProductLimit

Post by edu27 » 20 May 2024, 08:12

Hello again.

I want to use the plugin ProductLimit but when I add 2 or more items to the basket it gives me a generic error "At least one product couldn't be added to the basket." instead the one that is supposed to display: "The maximum product quantity is 1"
Captura de pantalla 2024-05-20 100943.png
Captura de pantalla 2024-05-20 100943.png (84.83 KiB) Viewed 32989 times
This happens when you add the product items from a product list like the main shop page. If you push the plus one button inside the basket view it works as expected and shows the correct message "The maximum product quantity is 1".
Captura de pantalla 2024-05-20 101046.png
Captura de pantalla 2024-05-20 101046.png (81.42 KiB) Viewed 32989 times
Packages installed:
aimeos-extensions/mysuitepacks dev-feature/AIMEOS
aimeos-themes/mysuite dev-feature/AIMEOS
aimeos/ai-admin-graphql 2024.04.1
aimeos/ai-admin-jqadm 2024.04.5
aimeos/ai-admin-jsonadm 2024.04.1
aimeos/ai-client-html 2024.04.3
aimeos/ai-client-jsonapi 2024.04.1
aimeos/ai-cms-grapesjs 2024.04.5
aimeos/ai-controller-frontend 2024.04.1
aimeos/ai-controller-jobs 2024.04.2
aimeos/ai-laravel 2024.04.1
aimeos/ai-payments 2024.04.2
aimeos/aimeos-base 2024.04.1
aimeos/aimeos-core 2024.04.5
aimeos/aimeos-laravel 2024.04.1
aimeos/macro 1.0.0
aimeos/map 3.7.0
aimeos/upscheme 0.8.9
laravel/framework v10.48.10
PHP 8.1

This is the error log:
Aimeos\MShop\Plugin\Provider\Exception: The maximum product quantity is 1 in /home/vagrant/suitacademystudents/vendor/aimeos/aimeos-core/src/MShop/Plugin/Provider/Order/ProductLimit.php:160
Stack trace:
#0 /home/vagrant/suitacademystudents/vendor/aimeos/aimeos-core/src/MShop/Plugin/Provider/Order/ProductLimit.php(134): Aimeos\MShop\Plugin\Provider\Order\ProductLimit->checkWithoutCurrency()
#1 /home/vagrant/suitacademystudents/vendor/aimeos/aimeos-core/src/MShop/Plugin/Provider/Decorator/Log.php(54): Aimeos\MShop\Plugin\Provider\Order\ProductLimit->update()
#2 /home/vagrant/suitacademystudents/vendor/aimeos/aimeos-core/src/MShop/Plugin/Provider/Decorator/Singleton.php(42): Aimeos\MShop\Plugin\Provider\Decorator\Log->update()
#3 /home/vagrant/suitacademystudents/vendor/aimeos/aimeos-core/src/MShop/Order/Item/Publisher.php(63): Aimeos\MShop\Plugin\Provider\Decorator\Singleton->update()
#4 /home/vagrant/suitacademystudents/vendor/aimeos/aimeos-core/src/MShop/Order/Item/Base.php(553): Aimeos\MShop\Order\Item\Base->notify()
#5 /home/vagrant/suitacademystudents/vendor/aimeos/ai-controller-frontend/src/Controller/Frontend/Basket/Standard.php(358): Aimeos\MShop\Order\Item\Base->addProduct()
#6 /home/vagrant/suitacademystudents/vendor/aimeos/ai-controller-frontend/src/Controller/Frontend/Basket/Decorator/Category.php(59): Aimeos\Controller\Frontend\Basket\Standard->addProduct()
#7 /home/vagrant/suitacademystudents/vendor/aimeos/ai-controller-frontend/src/Controller/Frontend/Basket/Decorator/Bundle.php(44): Aimeos\Controller\Frontend\Basket\Decorator\Category->addProduct()
#8 /home/vagrant/suitacademystudents/vendor/aimeos/ai-controller-frontend/src/Controller/Frontend/Basket/Decorator/Select.php(43): Aimeos\Controller\Frontend\Basket\Decorator\Bundle->addProduct()
#9 /home/vagrant/suitacademystudents/vendor/aimeos/ai-client-html/src/Client/Html/Basket/Standard/Standard.php(233): Aimeos\Controller\Frontend\Basket\Decorator\Select->addProduct()
#10 /home/vagrant/suitacademystudents/vendor/aimeos/ai-client-html/src/Client/Html/Basket/Standard/Standard.php(95): Aimeos\Client\Html\Basket\Standard\Standard->addProducts()
#11 /home/vagrant/suitacademystudents/vendor/aimeos/ai-client-html/src/Client/Html/Common/Decorator/Exceptions.php(107): Aimeos\Client\Html\Basket\Standard\Standard->init()
#12 /home/vagrant/suitacademystudents/vendor/aimeos/ai-client-html/src/Client/Html/Common/Decorator/Base.php(153): Aimeos\Client\Html\Common\Decorator\Exceptions->init()
#13 /home/vagrant/suitacademystudents/vendor/aimeos/aimeos-laravel/src/Base/Shop.php(65): Aimeos\Client\Html\Common\Decorator\Base->init()
#14 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(355): Aimeos\Shop\Base\Shop->get()
#15 /home/vagrant/suitacademystudents/vendor/aimeos/aimeos-laravel/src/Controller/BasketController.php(32): Illuminate\Support\Facades\Facade::__callStatic()
#16 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): Aimeos\Shop\Controller\BasketController->indexAction()
#17 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\Routing\Controller->callAction()
#18 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/Route.php(260): Illuminate\Routing\ControllerDispatcher->dispatch()
#19 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\Routing\Route->runController()
#20 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/Router.php(806): Illuminate\Routing\Route->run()
#21 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#22 /home/vagrant/suitacademystudents/vendor/spatie/laravel-blade-comments/src/Http/Middleware/AddRequestComments.php(16): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#23 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Spatie\BladeComments\Http\Middleware\AddRequestComments->handle()
#24 /home/vagrant/suitacademystudents/app/Http/Middleware/DebugMiddleware.php(28): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#25 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\Http\Middleware\DebugMiddleware->handle()
#26 /home/vagrant/suitacademystudents/app/Http/Middleware/LastVisit.php(28): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#27 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\Http\Middleware\LastVisit->handle()
#28 /home/vagrant/suitacademystudents/app/Http/Middleware/Locale.php(43): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#29 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\Http\Middleware\Locale->handle()
#30 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#31 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Routing\Middleware\SubstituteBindings->handle()
#32 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#33 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle()
#34 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Session/Middleware/AuthenticateSession.php(60): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#35 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Session\Middleware\AuthenticateSession->handle()
#36 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#37 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#38 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#39 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest()
#40 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Session\Middleware\StartSession->handle()
#41 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#42 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#43 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#44 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Cookie\Middleware\EncryptCookies->handle()
#45 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#46 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\Pipeline\Pipeline->then()
#47 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/Router.php(784): Illuminate\Routing\Router->runRouteWithinStack()
#48 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/Router.php(748): Illuminate\Routing\Router->runRoute()
#49 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Routing/Router.php(737): Illuminate\Routing\Router->dispatchToRoute()
#50 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\Routing\Router->dispatch()
#51 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#52 /home/vagrant/suitacademystudents/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#53 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle()
#54 /home/vagrant/suitacademystudents/vendor/spatie/laravel-cookie-consent/src/CookieConsentMiddleware.php(12): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#55 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Spatie\CookieConsent\CookieConsentMiddleware->handle()
#56 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#57 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Http\Middleware\TrustProxies->handle()
#58 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#59 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#60 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()
#61 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#62 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#63 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\TrimStrings->handle()
#64 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#65 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
#66 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(99): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#67 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()
#68 /home/vagrant/suitacademystudents/app/Http/Middleware/Cors.php(18): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#69 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\Http\Middleware\Cors->handle()
#70 /home/vagrant/suitacademystudents/app/Http/Middleware/AuthorizationToolMiddleware.php(19): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#71 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\Http\Middleware\AuthorizationToolMiddleware->handle()
#72 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#73 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\Pipeline\Pipeline->then()
#74 /home/vagrant/suitacademystudents/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#75 /home/vagrant/suitacademystudents/public/index.php(59): Illuminate\Foundation\Http\Kernel->handle()
#76 {main}
Thanks,
Eduardo.

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

Re: Error throwing exception in Plugin ProductLimit

Post by aimeos » 22 May 2024, 12:40

You have configured the ProductLimit plugin to only allow a quantity of "1". Please share your ProductLimit plugin configuration.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

edu27
Posts: 9
Joined: 04 Mar 2020, 19:40

Re: Error throwing exception in Plugin ProductLimit

Post by edu27 » 23 May 2024, 08:05

This is the plugin configuration.
Captura de pantalla 2024-05-23 100343.png
Captura de pantalla 2024-05-23 100343.png (52.99 KiB) Viewed 31840 times

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

Re: Error throwing exception in Plugin ProductLimit

Post by aimeos » 23 May 2024, 09:38

"single-number-max: 1" allows only one product of each available product in the basket
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

edu27
Posts: 9
Joined: 04 Mar 2020, 19:40

Re: Error throwing exception in Plugin ProductLimit

Post by edu27 » 23 May 2024, 14:54

Yes, I know that, but the thing is that is giving me a default error message instead of displaying the correct message. 'The maximum product quantity is 1'. Also the behaviour is inconsistent and I don't know why.

This is also affecting me in a plugin that I'm developing and I can't show to customers the correct message error because of this "At least one product couldn't be added to the basket."

In this video you can see what do I mean. https://drive.google.com/file/d/124C8IB ... sp=sharing

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

Re: Error throwing exception in Plugin ProductLimit

Post by aimeos » 25 May 2024, 21:30

The problem are these try/catch blocks which are not used when updating the basket quantity:
https://github.com/aimeos/ai-client-htm ... #L200-L241

Guess, if they are removed, it works as expected.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

edu27
Posts: 9
Joined: 04 Mar 2020, 19:40

Re: Error throwing exception in Plugin ProductLimit

Post by edu27 » 27 May 2024, 08:05

Removing this try/catch block it works as expected.
Are you going to change this in ai-client-html module?

Thanks!

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

Re: Error throwing exception in Plugin ProductLimit

Post by aimeos » 28 May 2024, 07:39

The try/catch blocks have been removed in dev-master and 2024.04.x-dev of the aimeos/ai-client-html package. The change will be part of the next release.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

edu27
Posts: 9
Joined: 04 Mar 2020, 19:40

Re: Error throwing exception in Plugin ProductLimit

Post by edu27 » 28 May 2024, 08:02

Thanks for your help!

Post Reply