Carlos Ucha Posted December 27, 2020 Share Posted December 27, 2020 (edited) Hi developers! I was able to create orders programmatically on a custom module until 1.7.7.0 update. Now this exception is thrown:Shop context types other than "single shop" are not supported I tried adding this code lines without success $shop = new Shop(1); $employee = new Employee(1); $this->context->employee = $employee; $this->context->shop = $shop; Shop::setContext(Shop::CONTEXT_SHOP, $shop->id); Additional information PrestaShop version: 1.7.7.0 PHP version: 7.2.25 Any help would be very appreciated! Edited December 27, 2020 by satislent (see edit history) Link to comment Share on other sites More sharing options...
galanea Posted January 25, 2021 Share Posted January 25, 2021 Hi, Have you managed to fix this? Link to comment Share on other sites More sharing options...
Carlos Ucha Posted January 25, 2021 Author Share Posted January 25, 2021 Hi, I managed to fix it for some orders, however the error still prompts in some cases. I'll have to investigate more. $this->context->cart = $cart; $currency = new Currency($id_currency); $this->context->currency = $currency; $shop = new Shop($id_shop); $employee = new Employee(1); $this->context->employee = $employee; $this->context->shop = $shop; Shop::setContext(Shop::CONTEXT_SHOP, $shop->id); Link to comment Share on other sites More sharing options...
galanea Posted January 25, 2021 Share Posted January 25, 2021 Thanks I'm getting this with my payment method. It was fine with 1.7.6 but stopepd with 1.7.7 Uncaught PrestaShopBundle\\Exception\\NotImplementedException: Shop context types other than "single shop" are not supported in /src/PrestaShopBundle/Entity/Repository/StockManagementRepository.php:142 Part of the validation code: if (isset($cart_id) && $cart_id != null) { $context->employee = new Employee($idEmployee); $cart = new Cart($cart_id); $context->cart = $cart; if (!Validate::isLoadedObject($cart)) exit; Link to comment Share on other sites More sharing options...
abdullacm Posted February 9, 2021 Share Posted February 9, 2021 @Carlos Ucha are you able to fix this error ? Link to comment Share on other sites More sharing options...
Carlos Ucha Posted February 9, 2021 Author Share Posted February 9, 2021 Hello! No I didn't. I tried to select the shop programmatically but the error persists. So I deleted the error and now it works: @ src\PrestaShopBundle\Entity\Repository\CategoryRepository.php (1 hits) src\PrestaShopBundle\Entity\Repository\FeatureAttributeRepository.php (1 hits) src\PrestaShopBundle\Entity\Repository\StockManagementRepository.php (1 hits) I changed: if ($shop->getContextType() !== $shop::CONTEXT_SHOP) { //throw new NotImplementedException('Shop context types other than "single shop" are not supported'); $this->shopId = 1; }else{ $this->shopId = $shop->getContextualShopId(); } Also @ /classes/shop/Shop.php public function getContextualShopId() { if ($this->getContextType() !== self::CONTEXT_SHOP) { //throw new LogicException('The retrieval of the contextual shop id is only possible in "single shop mode".'); return 1; } return (int) self::$context_id_shop; } 1 Link to comment Share on other sites More sharing options...
844493_1508421536 Posted October 12, 2021 Share Posted October 12, 2021 Thank's CARLOS ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now