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
your vendor/component name is not correct please change it in di.xml file