Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wthijmen committed Dec 8, 2023
1 parent 29fcb16 commit 2cb7fb7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Setup/Migrations/ReplaceDpzRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@

class ReplaceDpzRange
{
/** @var string $pathName */
private string $pathName = 'myparcelnl_magento_postnl_settings/digital_stamp/active';
/** @var string $pathDigitalStampActive */
private $pathDigitalStampActive = 'myparcelnl_magento_postnl_settings/digital_stamp/active';

Check warning on line 14 in Setup/Migrations/ReplaceDpzRange.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Setup/Migrations/ReplaceDpzRange.php#L14

Avoid unused private fields such as '$pathDigitalStampActive'.

/** @var string $pathDigitalStampDefault */
private $pathDigitalStampDefault = 'myparcelnl_magento_postnl_settings/digital_stamp/default_weight';

/** @var \MyParcelNL\Magento\Setup\QueryBuilder $queryBuilder */
private QueryBuilder $queryBuilder;
private $queryBuilder;

/** @var \Magento\Framework\Setup\SchemaSetupInterface $setup */
private SchemaSetupInterface $setup;
private $setup;

/** @var array $replaceValues */
private array $replaceValues = [
private $replaceValues = [
'100',
'350',
];
Expand Down Expand Up @@ -58,14 +61,14 @@ public function updateRangeValue(): void
$query = $this->queryBuilder
->select('path', 'value')
->from($this->setup->getTable('core_config_data'))
->where('path = ?', $this->pathName);
->where(sprintf('path = \'%s\'', $this->pathDigitalStampDefault));

$result = $connection->fetchRow($query);
if ($result && in_array($result['value'], $this->replaceValues, true)) {
$query = $this->queryBuilder
->update($this->setup->getTable('core_config_data'))
->set('value', $this->newValue)
->where('path = ?', $this->pathName);
->where(sprintf('path = \'%s\'', $this->pathDigitalStampDefault));
$connection->query($query);
}
}
Expand Down

0 comments on commit 2cb7fb7

Please sign in to comment.