diff --git a/Helper/Retry.php b/Helper/Retry.php
index 50be221d..44a19426 100644
--- a/Helper/Retry.php
+++ b/Helper/Retry.php
@@ -7,6 +7,7 @@
use Signifyd\Connect\Model\ResourceModel\Casedata\CollectionFactory as CasedataCollectionFactory;
use Signifyd\Connect\Model\ResourceModel\Casedata as CasedataResourceModel;
use Signifyd\Connect\Logger\Logger;
+use Signifyd\Connect\Model\CasedataFactory;
class Retry extends AbstractHelper
{
@@ -25,24 +26,32 @@ class Retry extends AbstractHelper
*/
protected $logger;
+ /**
+ * @var CasedataFactory
+ */
+ protected $casedataFactory;
+
/**
* Retry constructor.
* @param Context $context
* @param CasedataCollectionFactory $casedataCollectionFactory
* @param CasedataResourceModel $casedataResourceModel
* @param Logger $logger
+ * @param CasedataFactory $casedataFactory
*/
public function __construct(
Context $context,
CasedataCollectionFactory $casedataCollectionFactory,
CasedataResourceModel $casedataResourceModel,
- Logger $logger
+ Logger $logger,
+ CasedataFactory $casedataFactory
) {
parent::__construct($context);
$this->casedataCollectionFactory = $casedataCollectionFactory;
$this->casedataResourceModel = $casedataResourceModel;
$this->logger = $logger;
+ $this->casedataFactory = $casedataFactory;
}
/**
@@ -72,13 +81,17 @@ public function getRetryCasesByStatus($status)
/** @var \Signifyd\Connect\Model\Casedata $case */
foreach ($casesCollection->getItems() as $case) {
- $retries = $case->getData('retries');
+ $caseToUpdate = $this->casedataFactory->create();
+ $this->casedataResourceModel->loadForUpdate($caseToUpdate, $case->getId());
+
+ $retries = $caseToUpdate->getData('retries');
$secondsAfterUpdate = $case->getData('seconds_after_update');
if ($secondsAfterUpdate > $retryTimes[$retries]) {
- $casesToRetry[$case->getId()] = $case;
- $case->setData('retries', $retries + 1);
- $this->casedataResourceModel->save($case);
+
+ $casesToRetry[$caseToUpdate->getId()] = $caseToUpdate;
+ $caseToUpdate->setData('retries', $retries + 1);
+ $this->casedataResourceModel->save($caseToUpdate);
}
}
diff --git a/Setup/InstallSchema.php b/Setup/Patch/Data/InstallConfig.php
similarity index 69%
rename from Setup/InstallSchema.php
rename to Setup/Patch/Data/InstallConfig.php
index 71d23c33..b46ad5c4 100644
--- a/Setup/InstallSchema.php
+++ b/Setup/Patch/Data/InstallConfig.php
@@ -1,22 +1,13 @@
dateTime = $dateTime;
}
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- */
- public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
+ public function apply()
{
try {
if ($this->scopeConfigInterface->isSetFlag('signifyd_connect/general/installation_date') === false) {
@@ -63,4 +56,22 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$this->logger->error($e->getMessage());
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+
+ ];
+ }
}
diff --git a/Setup/Patch/Data/UpdateOrderId.php b/Setup/Patch/Data/UpdateOrderId.php
new file mode 100644
index 00000000..4fd32182
--- /dev/null
+++ b/Setup/Patch/Data/UpdateOrderId.php
@@ -0,0 +1,85 @@
+schemaSetupInterface = $schemaSetupInterface;
+ $this->logger = $logger;
+ $this->configWriter = $configWriter;
+ }
+
+ public function apply()
+ {
+ $signifydConnectCase = $this->schemaSetupInterface->getTable('signifyd_connect_case');
+ $salesOrder = $this->schemaSetupInterface->getTable('sales_order');
+
+ try {
+ $this->schemaSetupInterface->getConnection()->query("UPDATE ". $signifydConnectCase ." JOIN " . $salesOrder . " ON " .
+ $signifydConnectCase .".order_increment = " . $salesOrder . ".increment_id SET " .
+ $signifydConnectCase .".order_id = " . $salesOrder . ".entity_id WHERE " .
+ $signifydConnectCase . ".magento_status='complete'");
+ } catch (\Exception $e) {
+ $this->logger->debug('Update order_id on magento status complete failed');
+ $this->configWriter->save("signifyd/general/upgrade4.3_inconsistency", "setup");
+ }
+
+ try {
+ $this->schemaSetupInterface->getConnection()->query("UPDATE ". $signifydConnectCase ." JOIN " . $salesOrder . " ON " .
+ $signifydConnectCase .".order_increment = " . $salesOrder . ".increment_id SET ".
+ $signifydConnectCase .".order_id = " . $salesOrder . ".entity_id WHERE ".
+ $signifydConnectCase . ".magento_status<>'complete'");
+ } catch (\Exception $e) {
+ $this->logger->debug('Update order_id on magento status different from complete failed');
+ $this->configWriter->save("signifyd/general/upgrade4.3_inconsistency", "setup");
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+
+ ];
+ }
+}
diff --git a/Setup/UpgradeSchema.php b/Setup/UpgradeSchema.php
deleted file mode 100644
index 77a68e1a..00000000
--- a/Setup/UpgradeSchema.php
+++ /dev/null
@@ -1,111 +0,0 @@
-configWriter = $configWriter;
- $this->scopeConfig = $scopeConfig;
- $this->logger = $logger;
- }
-
- /**
- * Upgrades DB schema for a module
- *
- * @param SchemaSetupInterface $setup
- * @param ModuleContextInterface $context
- */
- public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
- {
- $setup->startSetup();
-
- /**
- * On 3.6.0 we've added this setting to database, but it is not necessary because it is already
- * on config.xml file. So now this setting will be removed if has not been changed
- */
- if (version_compare($context->getVersion(), '3.7.0') < 0) {
- $asyncPaymentMethodsPath = 'signifyd/general/async_payment_methods';
- $asyncPaymentMethods = $this->scopeConfig->getValue($asyncPaymentMethodsPath);
-
- if ($asyncPaymentMethods == 'cybersource,adyen_cc') {
- $this->configWriter->delete($asyncPaymentMethodsPath);
- }
- }
-
- if (version_compare($context->getVersion(), '3.7.6') < 0) {
- $setup->getConnection()->addColumn($setup->getTable('signifyd_connect_case'), 'lock_start', [
- 'type' => Table::TYPE_INTEGER,
- 'nullable' => true,
- 'default' => null,
- 'comment' => 'Row lock start timestamp'
- ]);
- }
-
- if (version_compare($context->getVersion(), '4.0.0') >= 0) {
- $signifydConnectCase = $setup->getTable('signifyd_connect_case');
- $salesOrder = $setup->getTable('sales_order');
-
- try {
- $setup->getConnection()->query("UPDATE ". $signifydConnectCase ." JOIN " . $salesOrder . " ON " .
- $signifydConnectCase .".order_increment = " . $salesOrder . ".increment_id SET " .
- $signifydConnectCase .".order_id = " . $salesOrder . ".entity_id WHERE " .
- $signifydConnectCase . ".magento_status='complete'");
- } catch (\Exception $e) {
- $this->logger->debug('Update order_id on magento status complete failed');
- $this->configWriter->save("signifyd/general/upgrade4.3_inconsistency", "setup");
- }
-
- try {
- $setup->getConnection()->query("UPDATE ". $signifydConnectCase ." JOIN " . $salesOrder . " ON " .
- $signifydConnectCase .".order_increment = " . $salesOrder . ".increment_id SET ".
- $signifydConnectCase .".order_id = " . $salesOrder . ".entity_id WHERE ".
- $signifydConnectCase . ".magento_status<>'complete'");
- } catch (\Exception $e) {
- $this->logger->debug('Update order_id on magento status different from complete failed');
- $this->configWriter->save("signifyd/general/upgrade4.3_inconsistency", "setup");
- }
- }
-
- $setup->endSetup();
- }
-}
diff --git a/etc/db_schema.xml b/etc/db_schema.xml
index cc5e6a09..9fb164ca 100644
--- a/etc/db_schema.xml
+++ b/etc/db_schema.xml
@@ -23,6 +23,7 @@
+