Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOL-1287: do not overwrite exisisting technical name #678

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/Service/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void
$existingPaymentMethod = null;
}

$technicalName = '';

if ($existingPaymentMethod instanceof PaymentMethodEntity) {

Expand All @@ -183,19 +184,17 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void
'name' => $existingPaymentMethod->getName(),
];

# starting with Shopware 6.5.7.0 this has to be filled out
# so that you can still save the payment method in the administration
if ($this->versionCompare->gte('6.5.7.0')) {
BlackScorp marked this conversation as resolved.
Show resolved Hide resolved
$paymentMethodData['technicalName'] = self::TECHNICAL_NAME_PREFIX . $mollieName;
# we do a string cast here, since getTechnicalName will be not nullable in the future
$technicalName = (string)$existingPaymentMethod->getTechnicalName(); /** @phpstan-ignore-line */
}

$upsertData[] = $paymentMethodData;
} else {
# let's create a full parameter list of everything
# that our new payment method needs to have

$mollieName = $paymentMethod['description'];


$paymentMethodData = [
'handlerIdentifier' => $paymentMethod['handler'],
'pluginId' => $pluginId,
Expand All @@ -209,15 +208,19 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void
'mollie_payment_method_name' => $mollieName
],
];
}

# starting with Shopware 6.5.7.0 this has to be filled out
# so that you can still save the payment method in the administration
if ($this->versionCompare->gte('6.5.7.0')) {
$paymentMethodData['technicalName'] = self::TECHNICAL_NAME_PREFIX . $mollieName;
}
if (mb_strlen($technicalName) > 0) {
$technicalName = self::TECHNICAL_NAME_PREFIX . $mollieName;
boxblinkracer marked this conversation as resolved.
Show resolved Hide resolved
}

$upsertData[] = $paymentMethodData;
# starting with Shopware 6.5.7.0 this has to be filled out
# so that you can still save the payment method in the administration
if ($this->versionCompare->gte('6.5.7.0')) {
$paymentMethodData['technicalName'] = $technicalName;
}

$upsertData[] = $paymentMethodData;
}

if (count($upsertData) > 0) {
Expand Down
Loading