As soon as I enable a promotion and try to load a product I see the following error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "request_path" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Drupal\Core\Plugin\DefaultPluginManager->getDefinition('request_path') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('request_path', Array) (Line: 50)
Drupal\Core\Condition\ConditionManager->createInstance('request_path', Array) (Line: 81)
Drupal\Core\Plugin\DefaultLazyPluginCollection->initializePlugin('request_path') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('request_path') (Line: 26)
Drupal\Core\Condition\ConditionPluginCollection->get('request_path') (Line: 148)
Drupal\Component\Plugin\LazyPluginCollection->getIterator() (Line: 99)
Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 93)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 340)
Drupal\Core\Entity\Entity->access('view', NULL, 1) (Line: 56)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 259)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I've been unable to determine why this issue takes place, but as soon as I delete the promotion, the issue disappears.

Comments

chrisrikli created an issue. See original summary.

chrisrikli’s picture

Title: Promotions cause PluginNotFountException » Promotions cause PluginNotFoundException
chrisrikli’s picture

Adding to this issue...I can get past the system's inability to load the request_path plugin with a drush cr but then I hit this:

Drupal\Core\Entity\EntityStorageException: The "commerce_promotion_order_total_price" plugin does not exist. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 770 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Drupal\Core\Plugin\DefaultPluginManager->getDefinition('commerce_promotion_order_total_price') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('commerce_promotion_order_total_price', Array) (Line: 84)
Drupal\Component\Plugin\PluginManagerBase->createInstance('commerce_promotion_order_total_price', Array) (Line: 124)
Drupal\commerce\Plugin\Field\FieldType\PluginItem->getTargetInstance(Array) (Line: 261)
Drupal\commerce_promotion\Entity\Promotion->applies(Object) (Line: 46)
Drupal\commerce_promotion\PromotionOrderProcessor->process(Object) (Line: 152)
Drupal\commerce_order\OrderRefresh->refresh(Object) (Line: 92)
Drupal\commerce_order\OrderStorage->doPreSave(Object) (Line: 389)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 761)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 364)
Drupal\Core\Entity\Entity->save() (Line: 90)
Drupal\commerce_cart\CartProvider->createCart('default', Object) (Line: 187)
Drupal\commerce_cart\Form\AddToCartForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('commerce_order_item_default_add_to_cart_1_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('commerce_order_item_default_add_to_cart_1_form', Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add_to_cart', Array) (Line: 67)
Drupal\commerce_product\ProductLazyBuilders->addToCartForm('35220', 'full', 1)
call_user_func_array(Array, Array) (Line: 356)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 47)
__TwigTemplate_c1833ffc648b3b539e9bf620ed7842baa7837169f99c5fb9a6fa7268640aa7f0->doDisplay(Array, Array) (Line: 428)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 396)
Twig_Template->display(Array) (Line: 407)
Twig_Template->render(Array) (Line: 64)
twig_render_template('modules/contrib/commerce/modules/product/templates/commerce-product.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('commerce_product', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Of course this plugin exists as part of the module out of the box.

bojanz’s picture

I've recently seen both errors as well, on a local install. Need to try and reproduce it again.

What's weird is that both of these plugins definitely exist, one provided by core, the other provided by commerce_promotion.
Smells like half-built discovery caches.

a.dmitriiev’s picture

I found this error also locally. I traced it down to this file modules\promotion\src\PromotionConditionManager.php and this class PromotionConditionManager.
In construct method now 'condition_plugins' is used as CacheBackend and I assume this is not correct, because core conditions are not compatible with commerce promotion conditions.

My suggestion is to change the constructor like this:

  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager) {
    parent::__construct('Plugin/Commerce/PromotionCondition', $namespaces, $module_handler, 'Drupal\commerce_promotion\Plugin\Commerce\PromotionCondition\PromotionConditionInterface', 'Drupal\commerce_promotion\Annotation\CommercePromotionCondition');

    $this->alterInfo('commerce_promotion_condition_info');
    $this->setCacheBackend($cache_backend, 'commerce_promotion_condition_plugins');
    $this->entityTypeManager = $entity_type_manager;
  }

I just added the prefix to alter hook and to cache backend key

This fixed the error for me.

  • bojanz committed c0d91f6 on 8.x-2.x authored by a.dmitriiev
    Issue #2832797 by bojanz, a.dmitriiev: Promotions cause...
bojanz’s picture

Status: Active » Fixed

Thanks a.dmitriiev, that did the trick.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.