From 1211aa3df139a434385d3c625a7153351b0b5226 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Wed, 7 Aug 2024 10:51:22 +0200 Subject: [PATCH] Fix save of meta profile --- Service/SequenceManagement.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Service/SequenceManagement.php b/Service/SequenceManagement.php index 9e75dc4..d6395e9 100644 --- a/Service/SequenceManagement.php +++ b/Service/SequenceManagement.php @@ -12,6 +12,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\SalesSequence\Model\Builder; use Magento\SalesSequence\Model\EntityPool; +use Magento\SalesSequence\Model\Profile; use Magento\SalesSequence\Model\ResourceModel\Meta as MetaResource; use Opengento\SalesSequence\Model\Config; @@ -64,18 +65,22 @@ private function create(string $entityType, int $storeId): void private function update(string $entityType, int $storeId): void { $meta = $this->metaResource->loadByEntityTypeAndStore($entityType, $storeId); - if (!$meta->getEntityId()) { + if (!$meta->getData('meta_id')) { throw NoSuchEntityException::doubleField('entity_type', $entityType, 'store_id', $storeId); } + $activeProfile = $meta->getData('active_profile'); + if ($activeProfile instanceof Profile) { + $meta->setHasDataChanges(true); + $activeProfile->addData([ + 'prefix' => $this->config->getPrefix($entityType, $storeId), + 'suffix' => $this->config->getSuffix($entityType, $storeId), + 'start_value' => $this->config->getStartValue($entityType, $storeId), + 'step' => $this->config->getStep($entityType, $storeId), + 'warning_value' => $this->config->getWarningValue($entityType, $storeId), + 'max_value' => $this->config->getMaxValue($entityType, $storeId) + ]); + } - $meta->addData([ - 'prefix' => $this->config->getPrefix($entityType, $storeId), - 'suffix' => $this->config->getSuffix($entityType, $storeId), - 'start_value' => $this->config->getStartValue($entityType, $storeId), - 'step' => $this->config->getStep($entityType, $storeId), - 'warning_value' => $this->config->getWarningValue($entityType, $storeId), - 'max_value' => $this->config->getMaxValue($entityType, $storeId) - ]); $this->metaResource->save($meta); } }