Magento verifica qué usuario ha agregado un producto
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/
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="catalog_product_save_after">
<observer name="observer_name" instance="vendor\module\Observer\ProductSaveAfter" />
</event>
</config>
Add ProductSaveAfter.php at vendor/module/Observer/
<?php
namespace vendor\module\Observer;
use Magento\Framework\Event\ObserverInterface;
class ProductSaveAfter implements ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
$instance = \Magento\Framework\App\ObjectManager::getInstance();
$productId = (int) $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);
}
}
Dharmesh Tukadiya