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

Fixes that data patches would not properly resolve table names #115

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions Setup/Patch/Data/CronJobPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ public function apply()
{
$this->moduleDataSetup->getConnection()->startSetup();

$previousValue = $this->moduleDataSetup->getConnection()->fetchOne('SELECT `value` FROM core_config_data WHERE path = "payment/mondu/require_invoice"');
$tableName = $this->moduleDataSetup->getTable('core_config_data');
$previousValue = $this->moduleDataSetup->getConnection()->fetchOne('SELECT `value` FROM ' . $tableName . ' WHERE `path` = "payment/mondu/require_invoice"');

if ($previousValue) {
$this->moduleDataSetup
->getConnection()
->delete('core_config_data', ['path = "payment/mondu/cron_require_invoice"']);
->delete($tableName, ['path = "payment/mondu/cron_require_invoice"']);

$this->moduleDataSetup->getConnection()->insert('core_config_data', [
$this->moduleDataSetup->getConnection()->insert($tableName, [
'scope' => 'default',
'scope_id' => 0,
'path' => 'payment/mondu/cron_require_invoice',
Expand Down
13 changes: 7 additions & 6 deletions Setup/Patch/Data/WebhookSecretPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@ public function apply()
{
$this->moduleDataSetup->getConnection()->startSetup();

$liveWebhookSecret = $this->moduleDataSetup->getConnection()->fetchOne('SELECT `value` FROM core_config_data WHERE path = "payment/mondu/live_webhook_secret"');
$sandboxWebhookSecret = $this->moduleDataSetup->getConnection()->fetchOne('SELECT `value` FROM core_config_data WHERE path = "payment/mondu/sandbox_webhook_secret"');
$tableName = $this->moduleDataSetup->getTable('core_config_data');
$liveWebhookSecret = $this->moduleDataSetup->getConnection()->fetchOne('SELECT `value` FROM ' . $tableName . ' WHERE `path` = "payment/mondu/live_webhook_secret"');
$sandboxWebhookSecret = $this->moduleDataSetup->getConnection()->fetchOne('SELECT `value` FROM ' . $tableName . ' WHERE `path` = "payment/mondu/sandbox_webhook_secret"');

$this->moduleDataSetup->getConnection()->delete('core_config_data', ['path = "payment/mondu/sandbox_webhook_secret"']);
$this->moduleDataSetup->getConnection()->delete('core_config_data', ['path = "payment/mondu/live_webhook_secret"']);
$this->moduleDataSetup->getConnection()->delete($tableName, ['path = "payment/mondu/sandbox_webhook_secret"']);
$this->moduleDataSetup->getConnection()->delete($tableName, ['path = "payment/mondu/live_webhook_secret"']);

$this->moduleDataSetup->getConnection()->insert('core_config_data', [
$this->moduleDataSetup->getConnection()->insert($tableName, [
'scope' => 'default',
'scope_id' => 0,
'path' => 'payment/mondu/sandbox_webhook_secret',
'value' => $sandboxWebhookSecret,
]);

$this->moduleDataSetup->getConnection()->insert('core_config_data', [
$this->moduleDataSetup->getConnection()->insert($tableName, [
'scope' => 'default',
'scope_id' => 0,
'path' => 'payment/mondu/live_webhook_secret',
Expand Down
54 changes: 28 additions & 26 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
showInStore="1">
<label>Api Configuration</label>
<field id="mondu_key" translate="label" type="obscure" sortOrder="30" showInDefault="1"
showInWebsite="1" showInStore="1">
showInWebsite="1" showInStore="1" canRestore="1">
<label>Api key</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/mondu/mondu_key</config_path>
</field>
<field id="mondu_send_lines" translate="label" type="select" sortOrder="31" showInDefault="1"
showInWebsite="0" showInStore="0">
showInWebsite="0" showInStore="0" canRestore="1">
<label>Send order line items</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/mondu/send_lines</config_path>
</field>
<field id="mondu_require_invoice" translate="label" type="select" sortOrder="32" showInDefault="1"
showInWebsite="0" showInStore="0">
showInWebsite="0" showInStore="0" canRestore="1">
<label>Require invoice for shipment</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/mondu/require_invoice</config_path>
</field>
<field id="sandbox" translate="label" type="select" sortOrder="85" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Sandbox mode</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/mondu/sandbox</config_path>
Expand All @@ -40,112 +40,112 @@

<label>General configuration</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Enable Bank Transfer</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/mondu/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Bank Transfer Title</label>
<config_path>payment/mondu/title</config_path>
</field>
<field id="description" translate="label" type="textarea" sortOrder="3" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Bank Transfer Description</label>
<config_path>payment/mondu/description</config_path>
</field>
<field id="activesepa" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Enable SEPA Direct Debit</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/mondusepa/active</config_path>
</field>
<field id="sepa_title" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>SEPA Direct Debit Title</label>
<config_path>payment/mondusepa/title</config_path>
</field>
<field id="sepa_description" translate="label" type="textarea" sortOrder="6" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>SEPA Direct Debit Description</label>
<config_path>payment/mondusepa/description</config_path>
</field>
<field id="activeinstallment" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Enable Split Payments</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/monduinstallment/active</config_path>
</field>
<field id="installment_title" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Split Payments Title</label>
<config_path>payment/monduinstallment/title</config_path>
</field>
<field id="installment_description" translate="label" type="textarea" sortOrder="9" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Split Payments Description</label>
<config_path>payment/monduinstallment/description</config_path>
</field>
<field id="activeinstallmentbyinvoice" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Enable Installments By Invoice</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/monduinstallmentbyinvoice/active</config_path>
</field>
<field id="installment_by_invoice_title" translate="label" type="text" sortOrder="11" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Installments by Invoice Title</label>
<config_path>payment/monduinstallmentbyinvoice/title</config_path>
</field>
<field id="installment_by_invoice_description" translate="label" type="textarea" sortOrder="12" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Installments by Invoice Description</label>
<config_path>payment/monduinstallmentbyinvoice/description</config_path>
</field>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="14" showInDefault="9"
showInWebsite="1" showInStore="1">
showInWebsite="1" showInStore="1" canRestore="1">
<label>Payment From Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<config_path>payment/mondu/allowspecific</config_path>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="15" showInDefault="1"
showInWebsite="1" showInStore="1">
showInWebsite="1" showInStore="1" canRestore="1">
<label>Payment From Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<config_path>payment/mondu/specificcountry</config_path>
</field>

<field id="mondusortorder" translate="label" type="text" sortOrder="16" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Bank Transfer Sort Order</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/mondu/sort_order</config_path>
</field>

<field id="mondusepasortorder" translate="label" type="text" sortOrder="17" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>SEPA Direct Debit Sort Order</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/mondusepa/sort_order</config_path>
</field>

<field id="monduinstallmentsortorder" translate="label" type="text" sortOrder="18" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Split Payments Sort Order</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/monduinstallment/sort_order</config_path>
</field>

<field id="monduinstallmentbyinvoicesortorder" translate="label" type="text" sortOrder="19" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Installments By Invoice Sort Order</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/monduinstallmentbyinvoice/sort_order</config_path>
</field>

<field id="debug" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1"
showInStore="1">
showInStore="1" canRestore="1">
<label>Enable Logs</label>
<config_path>payment/mondu/debug</config_path>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
Expand All @@ -156,19 +156,21 @@
<label>Cron configuration</label>

<field id="cron" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0"
showInStore="0">
showInStore="0" canRestore="1">
<label>Enable Cron job for sending invoices to Mondu</label>
<config_path>payment/mondu/cron</config_path>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>

<field id="monducron_status" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="monducron_status" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="0"
showInStore="0" canRestore="1">
<label>Order status in which order will be processed by the Cron job</label>
<config_path>payment/mondu/cron_status</config_path>
<source_model>Magento\Sales\Model\Config\Source\Order\Status</source_model>
</field>

<field id="monducron_requireinvoice" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="monducron_requireinvoice" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="0"
showInStore="0" canRestore="1">
<label>Require Invoice document for processing orders</label>
<config_path>payment/mondu/cron_require_invoice</config_path>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
Expand Down