- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2021
09:58 PM
01-29-2021
09:58 PM
Plugin class doesn't exist
Hi Guys,
I have created a very simple plugin but at the time of compile code (run bin/magento setup:di:compile command) it show Plugin class doesn't exist. Below is my module code
Module structure:
Webkeon\DynamicProduct
registration.php code
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Webkeon_DynamicProduct', __DIR__ );
Webkeon\DynamicProduct\etc
module.xml code
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Webkeon_DynamicProduct" setup_version="0.0.2"> </module> </config>
di.xml code
<?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Quote\Model\Quote\Item"> <plugin name="Wekeon_DynamicProduct_Plugin_Magento_Quote_Model_Quote_Item" type="Wekeon\DynamicProduct\Plugin\ItemPlugin" sortOrder="1" disabled="false" /> </type> </config>
Webkeon\DynamicProduct\Plugin
ItemPlugin.php code
<?php namespace Webkeon\DynamicProduct\Plugin; class ItemPlugin { public function afterSetProduct(\Magento\Quote\Model\Quote\Item $subject,$result){ $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/productplugin.log'); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $logger->debug('product name plugin <br>'); $subject->setName('New Name'); } }
Any one let me know where i am doing wrong it is very simple plugin that are overwriting public function.
Thanks
Sanjeev
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2021
02:22 AM
08-14-2021
02:22 AM
Re: Plugin class doesn't exist
your vendor/component name is not correct please change it in di.xml file
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework
bjectManager/etc/config.xsd">
![Smiley Surprised Smiley Surprised](/i/smilies/16x16_smiley-surprised.png)
<type name="Magento\Quote\Model\Quote\Item">
<plugin name="Wekeon_DynamicProduct_Plugin_Magento_Quote_Model_Quote_Item"
type="Webkeon\DynamicProduct\Plugin\ItemPlugin" sortOrder="1" disabled="false" />
</type>
</config>
thanks