1

i have custom attribute ("current_seller_id") in sales_shipment_item table and want to save custom value in it when click on submit invoice

Can any one tell me which event or use plugin method for saving value when data save in sales_shipment_item table.

And also find to know same value save in sales_shipment table. current_seller_id attribute also in sales_shipment table.

Please guide me little bit which event use or plugin ? Thanks in advance

0

VendorName/ModuleName/etc/event.xml Past this code

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
 <event name="sales_order_shipment_save_before">
        <observer name="set_attribute_in_order" instance="VendorName/ModuleName\Observer\Shipment" />
    </event>
</config>

make class that define in instance in VendorName/ModuleName\Observer\Shipment

and Past this code my custom attribute is current_seller_id

<?php
namespace Codility\VendorOrder\Observer;

use Magento\Framework\Event\ObserverInterface;

class Shipment implements ObserverInterface
{
    protected $authSession;
    public function __construct( \Magento\Backend\Model\Auth\Session $authSession,
                                 \Magento\Catalog\Model\Product $product)
    {
        $this->authSession=$authSession;
    }
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $current_user_id=$this->authSession->getUser()->getUserId();
        $shipment = $observer->getEvent()->getShipment();
        foreach ($shipment->getItemsCollection() as $item) {
            $item->setCurrentSellerId($current_user_id);
        }
        return $this;
    }
}

This code save value in sales_Shipment_items now as same i want to save value in sales_shippment table. which method i can make plugin or event ?

  • @MohitKumarArora is not edit my question . it answer of my question read carefully – HaFiz Umer Mar 27 at 5:54
  • Okay @Hafiz-umer, I accept my mistake. – Mohit Kumar Arora Mar 27 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.