1

I would like to post some data in admin order create form and check if it exists and is set if not throw an exception.

I was thinking about adminhtml_sales_order_create_process_data event, but it is called several times. I think it would be nice to have some sort of event before the admin order is saved and check if this data exists.

1
  • Maybe is "sales_order_save_before". Magento use it in \Magento\Payment\Observer\SalesOrderBeforeSaveObserver for set canCreditmemo flag.
    – sergei.sss
    Mar 2, 2017 at 10:49

1 Answer 1

0

Create a plugin for Sales/Model/Order by putting smth like this in your module, in di.xml

<type name="Magento\Sales\Model\Order">
    <plugin name="YOUR NAME" type="Your-Module\Sales\Plugin\Sales\Model\Order" sortOrder="10" disabled="false"/>
</type>

Then, in Order.php create

public function beforeSave(\Magento\Sales\Model\Order $subject)
{
$subject->getData() 
// this is your order Data before saving it
}

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.