0

I have created around plugin for isAttributeValid function for Magento\ImportExport\Model\Import\Entity\AbstractEntity but it is not working. code: <type name="Magento\ImportExport\Model\Import\Entity\AbstractEntity"> <plugin name="bbb" type="xxxx\yyy\Plugin\Entity\AbstractEntity" sortOrder="10" /> </type>

in the plugin:

<?php
namespace XXX\YYY\Plugin\Entity;

class AbstractEntity
{
    public function aroundIsAttributeValid(
        $subject, $attrCode, $result) {
        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
        $logger = new \Zend\Log\Logger();
        $logger->addWriter($writer);
        $logger->info('hhhuu'); 
        echo "hhh";exit();
        $returnValue = $subject;
        return $returnValue;

    }

}

but echo is not printed.

  • what is the location of di.xml ? – Pawan Apr 9 '20 at 15:00
  • Global location – Jothi Subramanian Apr 9 '20 at 15:11
  • could you plz tell when isAttributeValid is called ? – Pawan Apr 10 '20 at 6:07
  • It was called in Magento\CatalogImportExport\Model\Import\Product.php – Jothi Subramanian Apr 13 '20 at 10:00
  • I want to ask, in admin when IsAttributeValid is called so i can check override is working or not – Pawan Apr 13 '20 at 11:09
0

Try adding a log file -
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log'); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $logger->info('Your text message');

0

There's an error in your method name:

aroundisAttributeValid should be aroundIsAttributeValid (note the capital "I"). Also, I'm not sure if your parameter $result should exist - you may need to check that. Another thing, you may need to check the scope (frontend, admin, global) in which you're defining the plugin. This can also influence if it works or not.

  • I have changed aroundIsAttributeValid .still it is not working – Jothi Subramanian Apr 9 '20 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.