Skip to content

Commit

Permalink
Fix Config update different scope types
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 authored Aug 7, 2024
1 parent be3c29d commit 0fbbfdf
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Observer/SequenceUpdaterObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}
}
}

0 comments on commit 0fbbfdf

Please sign in to comment.