magento check which user has added a product
First of all create a custom attribute called : "updated_by" from magento backend and don't forget to drag that into default attribute set otherwise it will not work!!
Add events.xml file to vendor/module/etc/adminhtml/
Add ProductSaveAfter.php at vendor/module/Observer/
getProduct()->getId();
$user = $instance->get('Magento\Backend\Model\Auth\Session')->getUser()->getUsername();
$action = $instance->create('Magento\Catalog\Model\Product\Action');
$action->updateAttributes([$productId], array('updated_by' => $user), 0);
}
}
|