Search
 
SCRIPT & CODE EXAMPLE
 

PHP

magento update attribute value without using object manager

        <?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
        }
    }
Comment

PREVIOUS NEXT
Code Example
Php :: Drupal config_readonly 
Php :: trying to change iframe location from javascript 
Php :: check value is email or mobilenumber using php 
Php :: all locales php 
Php :: laravel components scripts 
Php :: woocommerce remove notification after some time 
Php :: php array_diff vs array_diff_assoc 
Php :: PHP (php 7.3.5) sample 
Php :: configurar pagina html php para mobile 
Php :: Update database table row if a qualifying token is provided 
Php :: pagenavi plugin 
Php :: create product model in laravel 
Php :: PHP 7 PDF page group - sizeof(): Parameter must be an array or an object that implements Countable 
Php :: Relationship 1-n multiple BACKPACK Laravel 
Php :: describe request php-salesforce-rest-api 
Php :: laravel eloquent order by relationship 
Php :: Maintenace Mode Up using cron 
Php :: phpfiddle 
Php :: create random username and password php 
Php :: retrieve data from database xampp 
Php :: upgrade phpopensuse 
Php :: PHP 7 - Fatal error: Call to undefined method PDF::FPDF() 
Php :: how to stop a query if query after it is not inserted in laravel 
Php :: how to add in massive php 
Php :: if condition in laravel blade in select option 
Php :: php to html 
Php :: php send to message to mobile number using springedge 
Php :: lowercase in array php 
Php :: yii framework 
Php :: php sort 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =