I've used the sales_order_save_before event scope is etc/events.xml - This is working fine but, etc/frontend/events.xml not working properly. sales_order_save_before event not support frontend scope?
2 Answers
The class which is reponsible for dispatching sales_order_save_before event is the model of order Magento\Sales\Model\Order. In order to get to the dispatch statement, you need to look for the beforeSave method into inheritance heirarchy of this model. If you do so, you will end up in Magento\Framework\Model\AbstractModel class which contains the save, beforeSave and afterSave methods.
public function beforeSave()
{
if (!$this->getId()) {
$this->isObjectNew(true);
}
$this->_eventManager->dispatch('model_save_before', ['object' => $this]);
$this->_eventManager->dispatch($this->_eventPrefix . '_save_before', $this->_getEventData());
return $this;
}
-
This is a beautiful answer: informative, concise, and generalized enough to apply to many situations. Commented Jul 5, 2022 at 6:12
And also In case you do not want to listen to the "sales_order_save_before" is global event , so it is use in etc/events.xml
-
Bro can you take a look at my question, its not related to your question, i just thought you may know the answer. here is my question magento.stackexchange.com/questions/358034/… Commented Jul 20, 2022 at 16:17
-