1

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?

AK_105917
  • 13
  • 4

2 Answers2

1

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;
 }
0

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 https://magento.stackexchange.com/questions/358034/magento2-4-how-to-sort-product-by-best-selling-and-best-reviewed-produc – Afzal Arshad Jul 20 '22 at 16:17
  • sure i can show it – Divyarajsinh Barad Jul 21 '22 at 07:11