0

I have created order attribute I also followed https://magento.stackexchange.com/a/236710/34850 & https://magento.stackexchange.com/a/302886/34850 which helped me creating custom field in admin create order form (phtml code below)

<input id="ponumber" name="order[ponumber]" value="" class="admin__control-text input-text" type="text" />

Now I want to save that value to order table for which I used below events sales_model_service_quote_submit_before, sales_order_save_before & sales_order_save_after But its not saving even tried printing logs, but logs didnt also worked on those observers

Can anyone please help me saving that attribute from admin create order form?

1 Answer 1

0

I found both method working, adding answer just if incase someone end up here

use event = sales_model_service_quote_submit_before & in its observer

$order = $observer->getOrder();
$quote = $this->quoteRepository->get($order->getQuoteId());
$order->setPonumber($quote->getPonumber());
return $this;

or use event = sales_order_save_after & in its observer

$order=$observer->getEvent()->getOrder();
$params=$this->_request->getPost();
if($params && isset($params['order']['ponumber']) && $params['order']['ponumber']!='')
{
    $order->setPonumber($params['order']['ponumber']);
    $order->save();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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