Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quick fix for an exception on multishipping order placememnt #63

Open
wants to merge 1 commit into
base: v5.2.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Observer/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,54 @@ public function __construct(
$this->jsonSerializer = $jsonSerializer;
}


/**
* Fix for multishipping
*
* @param Observer $observer
* @param bool $checkOwnEventsMethods
*/
public function execute(Observer $observer, $checkOwnEventsMethods = true)
{
/**
* If the observer contains an array of orders, we emulate
* receiving an observer for each particular order.
* That is done in order not to alter extension's logic.
*/
$orders = $observer->getOrders();
if (is_array($orders)) {
$eventName = $observer->getEvent()->getName();
$quote = $observer->getQuote();
$ownMethods = $observer->getCheckOwnEventsMethods();
foreach ($orders as $order) {
/**
* Please note that Magento instantiates events and observers without factories.
* @see \Magento\Staging\Model\Event\Manager::dispatch()
*/
$event = new \Magento\Framework\Event([
'name' => $eventName,
'order' => $order,
'quote' => $quote,
'check_own_events_methods' => $ownMethods
]);
$orderObserver = new Observer([
'event' => $event,
'order' => $order,
'quote' => $quote,
'check_own_events_methods' => $ownMethods
]);
$this->processOrder($orderObserver, $checkOwnEventsMethods);
}
} else {
$this->processOrder($observer, $checkOwnEventsMethods);
}
}

/**
* @param Observer $observer
* @param bool $checkOwnEventsMethods
*/
public function processOrder(Observer $observer, $checkOwnEventsMethods = true)
{
try {
$this->logger->info('Processing Signifyd event ' . $observer->getEvent()->getName());
Expand Down