Add Event for sales_order_state_change_before during Order->saveState() #1199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Additionally refactored to remove unnecessary protected function
Refactored only call to the protected function to call the public function
Fixed up the docblock as well.
After looking through 6000 Magento 1.x extensions (https://gist.github.com/dfry22/474f727495228baccf28), noticed that the most common model rewrite in all of them (1 in 100 approx.) was
Mage_Sales_Model_Order
. After analyzing a large sample of these modules, noticed that the most common occurrence was a dispatch ofsales_order_status_change
.If this event can be worked into Magento 2, we can remove the need for superfluous plugins looking to intercept the
setState()
function.Also refactored the formerly protected
_saveState()
function, which was only being called once in the class itself, and also had no differences with the public function aside from one default parameter - so combined them into one function, and removed some outdated docblock comments.Used a transport object in dispatching the event so any modifications in observers are passed back into the function.