<?php
namespace vendormoduleObserver;
class ProductSaveAfter implements MagentoFrameworkEventObserverInterface
{
public function __construct(
MagentoBackendModelAuthSession $authSession,
MagentoCatalogModelProductFactory $productFactory
) {
$this->authSession = $authSession;
$this->productFactroy = $productFactory;
}
public function execute(MagentoFrameworkEventObserver $observer)
{
$user = $this->authSession->getUser()->getUsername();
$productId = (int) $observer->getProduct()->getId();
$product = $this->productFactroy->create()->load($productId);
$product->addAttributeUpdate("updated_by", $user, 0);//attribute,value,storeid
}
}