Skip to content

Commit aa975b9

Browse files
committed
Code refactor
1 parent 943b31c commit aa975b9

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed

Block/Adminhtml/System/Config/Form/Attention.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magefan\GoogleTagManager\Block\Adminhtml\System\Config\Form;
810

911
use Magento\Framework\Data\Form\Element\AbstractElement;
@@ -23,7 +25,7 @@ class Attention extends \Magefan\Community\Block\Adminhtml\System\Config\Form\In
2325
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
2426
{
2527
return '<div style="padding:10px;background-color:#ffe5e5;border:1px solid #ddd;margin-bottom:7px;">
26-
<strong>Attention!</strong> Once you change and save the settings,
28+
<strong>Attention!</strong> Once you change and save the "Web Container" or "Google Analytics 4" settings,
2729
please don\'t forget to scroll down to the "Export Container" section
2830
and click the "Generate JSON Container & Download File" button to export container data.
2931
After you save the file, <a target="_blank" title="Create GTM tags" href="https://magefan.com/blog/add-google-tag-manager-to-magento-2#5-create-gtm-tags">

Model/Config.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,23 +197,23 @@ public function getCategoriesAttribute(string $storeId = null): string
197197
}
198198

199199
/**
200-
* Retrieve store config value
201-
*
202-
* @param string $path
203200
* @param string|null $storeId
204-
* @return mixed
201+
* @return int
205202
*/
206-
public function getConfig(string $path, string $storeId = null)
203+
public function getGTMLoaderType(string $storeId = null): string
207204
{
208-
return $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeId);
205+
return (string)$this->getConfig(self::XML_PATH_GTM_LOADER_TYPE, $storeId);
209206
}
210207

211208
/**
209+
* Retrieve store config value
210+
*
211+
* @param string $path
212212
* @param string|null $storeId
213-
* @return int
213+
* @return mixed
214214
*/
215-
public function getGTMLoaderType(string $storeId = null): string
215+
public function getConfig(string $path, string $storeId = null)
216216
{
217-
return (string)$this->getConfig(self::XML_PATH_GTM_LOADER_TYPE, $storeId);
217+
return $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeId);
218218
}
219219
}

Model/LoaderPool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LoaderPool
2020
/**
2121
* LoaderPool constructor.
2222
* @param array $loaders
23-
// */
23+
*/
2424
public function __construct(array $loaders)
2525
{
2626
$this->loaders = $loaders;

Setup/Patch/Schema/ChangePath.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ public function apply()
4646
];
4747

4848
foreach ($changedConfigurationFields as $oldPath => $newPath) {
49-
$sql = 'UPDATE ' . $table . ' SET `path` = "' . $newPath . '" WHERE `path` = "' . $oldPath . '";';
50-
$this->schemaSetup->run($sql);
49+
$connection->update(
50+
$table,
51+
['path' => $newPath],
52+
['path = ?' => $oldPath]
53+
);
5154
}
5255

5356
$this->schemaSetup->endSetup();

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"email": "[email protected]"
1010
}
1111
],
12-
"version": "2.1.0",
12+
"version": "2.2.0",
1313
"require": {
14-
"magefan/module-community" : ">=2.1.13"
14+
"magefan/module-community" : ">=2.1.16"
1515
},
1616
"autoload": {
1717
"files": [

etc/adminhtml/system.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
<frontend_model>Magefan\Community\Block\Adminhtml\System\Config\Form\ProductKeyField</frontend_model>
3131
</field>
3232
</group>
33-
<group id="web_container" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
33+
<group id="web_container" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" >
3434
<label>Web Container</label>
3535
<attribute type="expanded">1</attribute>
36-
<field id="enable" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
36+
<field id="enable" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
3737
<label>Enable</label>
3838
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
3939
</field>

etc/config.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
<mfgoogletagmanager>
1111
<general>
1212
<enabled>0</enabled>
13+
<loader_type/>
1314
<mfmodule>GoogleTagManager</mfmodule>
1415
<mftype>1</mftype>
1516
</general>
1617
<web_container>
17-
<enable>0</enable>
18+
<enable>1</enable>
1819
<account_id/>
1920
<container_id/>
2021
<public_id/>
2122
</web_container>
2223
<analytics>
23-
<enable>0</enable>
24+
<enable>1</enable>
2425
<measurement_id/>
2526
</analytics>
2627
<attributes>

0 commit comments

Comments
 (0)