Commit 5889f9c6 authored by Dimitris Bozelos's avatar Dimitris Bozelos
Browse files

Issue #3308712 Do not set the AMWS store on skipped order imports

parent ae790d6d
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Drupal\commerce_amws_order\EventSubscriber;

use Drupal\commerce_amws\MachineName\Field\Order as OrderField;
use Drupal\entity_sync\Import\Event\Events;
use Drupal\entity_sync\Import\ManagerInterface;
use Drupal\entity_sync\Event\TerminateOperationEvent;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -36,7 +37,16 @@ class OrderSetAmwsStore implements EventSubscriberInterface {
      return;
    }

    $event->getData()['local_entity']->set(
    $data = $event->getData();
    // We only need to set the store the first time that the order is
    // created. No need to reset it on updates, and nothing to do on skips. If
    // the action was a skip, the `local_entity` wouldn't be available in the
    // data and we would be getting an error anyways.
    if ($data['action'] !== ManagerInterface::ACTION_CREATE) {
      return;
    }

    $data['local_entity']->set(
      OrderField::AMWS_STORE,
      ['target_id' => $event->getContext()['amws_store_id']]
    );