Skip to content

Commit

Permalink
Fix save of meta profile
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 authored Aug 7, 2024
1 parent 0fbbfdf commit 1211aa3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Service/SequenceManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 1211aa3

Please sign in to comment.