Skip to content

Commit

Permalink
Solve bug of unexisting integration while running data patch (#280)
Browse files Browse the repository at this point in the history
* Solve bug of unexisting integration while running data patch

* Improved code
  • Loading branch information
Aitor-Corrales committed Jun 6, 2023
1 parent 1f5efc3 commit 312e146
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Setup/Patch/Data/UpgradeIntegrationPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Doofinder\Feed\Setup\Patch\Data;

use Exception;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Integration\Api\IntegrationServiceInterface;
Expand Down Expand Up @@ -39,15 +40,14 @@ public function __construct(
public function apply()
{
$this->moduleDataSetup->startSetup();

$integration = $this->integrationService->findByName(self::DOOFINDER_INTEGRATION_NAME);

if ($integration) {
try {
$integration = $this->integrationService->findByName(self::DOOFINDER_INTEGRATION_NAME);
$integrationData = ['integration_id' => $integration->getId(), 'name' => $integration->getName(), 'resource' => $this->resources];
$this->integrationService->update($integrationData);
} catch(Exception $e) {
} finally {
$this->moduleDataSetup->endSetup();
}

$this->moduleDataSetup->endSetup();
}

public static function getDependencies()
Expand Down

0 comments on commit 312e146

Please sign in to comment.