diff --git a/Observer/SequenceUpdaterObserver.php b/Observer/SequenceUpdaterObserver.php index 6d17fce..8a8a8e5 100644 --- a/Observer/SequenceUpdaterObserver.php +++ b/Observer/SequenceUpdaterObserver.php @@ -15,6 +15,8 @@ use Magento\Store\Model\StoreManagerInterface; use Opengento\SalesSequence\Service\SequenceManagement; +use function array_keys; + class SequenceUpdaterObserver implements ObserverInterface { public function __construct( @@ -29,9 +31,16 @@ public function __construct( */ public function execute(EventObserver $observer): void { - $storeCode = (string)$observer->getData('store'); - if ($storeCode !== '') { - $this->sequenceManagement->createOrUpdate((int)$this->storeManager->getStore($storeCode)->getId()); + + $store = $observer->getData('store'); + $website = $observer->getData('website'); + $stores = match (true) { + $store !== null => [$this->storeManager->getStore($store)->getId()], + $website !== null => $this->storeManager->getWebsite($website)->getStoreIds(), + default => array_keys($this->storeManager->getStores()) + }; + foreach ($stores as $storeId) { + $this->sequenceManagement->createOrUpdate((int)$storeId); } } }