Carlos Ucha 0 Posted December 27, 2020 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) Share this post Link to post Share on other sites
galanea 0 Posted January 25 Posted January 25 Hi, Have you managed to fix this? Share this post Link to post Share on other sites
Carlos Ucha 0 Posted January 25 Posted January 25 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); Share this post Link to post Share on other sites
galanea 0 Posted January 25 Posted January 25 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; Share this post Link to post Share on other sites
Abdulla CM 3 Posted February 9 Posted February 9 @Carlos Ucha are you able to fix this error ? Share this post Link to post Share on other sites
Carlos Ucha 0 Posted February 9 Posted February 9 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; } Share this post Link to post Share on other sites
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