Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
2 added 15 characters in body
source | link

i createI have created 1 custom attribute (current_user_id) and savesaving value when product is savesaved. I have usecatalog_product_save_before event that save value for my custom attribute(current_user_id). code is

public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $_product = $observer->getProduct();  // you will get product object
        $current_users=$this->authSession->getUser();
        $current_admin_id=$current_users->getData('user_id');
        $_product->setCurrentUserId($current_admin_id) ;
    }

itIt work perfect for add single product.

But now iI want to add bulk products How this possible for import bulk product ?

I think we make custom attribute column in csv file and use which event that fire when import after check data. and foreach for setting value in custom attribute ? 
Please Guide me iI want to save custom attribute value in bulk products Thanks

i create 1 custom attribute (current_user_id) and save value when product is save. I have usecatalog_product_save_before event that save value for my custom attribute(current_user_id). code is

public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $_product = $observer->getProduct();  // you will get product object
        $current_users=$this->authSession->getUser();
        $current_admin_id=$current_users->getData('user_id');
        $_product->setCurrentUserId($current_admin_id) ;
    }

it work perfect for add single product.

But now i want to add bulk products How this possible for import bulk product ?

I think we make custom attribute column in csv file and use which event that fire when import after check data. and foreach for setting value in custom attribute ? Please Guide me i want to save custom attribute value in bulk products Thanks

I have created 1 custom attribute (current_user_id) and saving value when product is saved. I have usecatalog_product_save_before event that save value for my custom attribute(current_user_id). code is

public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $_product = $observer->getProduct();  // you will get product object
        $current_users=$this->authSession->getUser();
        $current_admin_id=$current_users->getData('user_id');
        $_product->setCurrentUserId($current_admin_id) ;
    }

It work perfect for add single product.

But now I want to add bulk products How this possible for import bulk product ?

I think we make custom attribute column in csv file and use which event that fire when import after check data. and foreach for setting value in custom attribute ? 
Please Guide me I want to save custom attribute value in bulk products Thanks

1
source | link

Magento 2 import bulk products with custom attribute

i create 1 custom attribute (current_user_id) and save value when product is save. I have usecatalog_product_save_before event that save value for my custom attribute(current_user_id). code is

public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $_product = $observer->getProduct();  // you will get product object
        $current_users=$this->authSession->getUser();
        $current_admin_id=$current_users->getData('user_id');
        $_product->setCurrentUserId($current_admin_id) ;
    }

it work perfect for add single product.

But now i want to add bulk products How this possible for import bulk product ?

I think we make custom attribute column in csv file and use which event that fire when import after check data. and foreach for setting value in custom attribute ? Please Guide me i want to save custom attribute value in bulk products Thanks