From c02d005c927bc4d8498bdb4cbb805b082d150fe4 Mon Sep 17 00:00:00 2001 From: Frederik Rommel Date: Wed, 18 Sep 2024 16:19:39 +0200 Subject: [PATCH] RATESWSX-315: fix missing plugin-id after remove and readd of plugin --- src/Bootstrap/PaymentMethods.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Bootstrap/PaymentMethods.php b/src/Bootstrap/PaymentMethods.php index 28304380..dc2f0983 100644 --- a/src/Bootstrap/PaymentMethods.php +++ b/src/Bootstrap/PaymentMethods.php @@ -135,9 +135,10 @@ private function addPaymentMethods(): void $criteria->addFilter(new EqualsFilter('handlerIdentifier', $paymentMethod['handlerIdentifier'])); $criteria->setLimit(1); - $id = $this->paymentRepository->searchIds($criteria, $this->defaultContext)->firstId(); + /** @var PaymentMethodEntity|null $entity */ + $entity = $this->paymentRepository->search($criteria, $this->defaultContext)->first(); - if ($id === null) { + if ($entity === null) { if (!$this->isFieldTechnicalNameAvailable()) { unset($paymentMethod['technicalName']); } @@ -145,6 +146,12 @@ private function addPaymentMethods(): void $paymentMethod['pluginId'] = $this->plugin->getId(); $paymentMethod['active'] = false; $upsertData[] = $paymentMethod; + } elseif ($entity->getPluginId() === null) { + // plugin has been installed in the past, but was removed and installed again. + $upsertData[] = [ + 'id' => $entity->getId(), + 'pluginId' => $this->plugin->getId(), + ]; } }