Skip to content

Commit b110bc2

Browse files
committed
Make backoffice marking working - install hidden tab for ajax controller
1 parent 264bdf6 commit b110bc2

5 files changed

Lines changed: 45 additions & 4 deletions

File tree

classes/Database/Install.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222

2323
use Configuration;
2424
use Db;
25+
use Language;
2526
use Ps_Googleanalytics;
2627
use Shop;
28+
use Tab;
2729

2830
class Install
2931
{
@@ -112,4 +114,24 @@ public function registerHooks()
112114
$this->module->registerHook('displayBackOfficeHeader') &&
113115
$this->module->registerHook('actionCarrierProcess');
114116
}
117+
118+
/**
119+
* Installs hidden tab for our ajax controller
120+
*
121+
* @return bool
122+
*/
123+
public function installTab()
124+
{
125+
$tab = new Tab();
126+
$tab->class_name = 'AdminGanalyticsAjax';
127+
$tab->module = $this->module->name;
128+
$tab->active = true;
129+
$tab->id_parent = -1;
130+
$tab->name = array_fill_keys(
131+
Language::getIDs(false),
132+
$this->module->displayName
133+
);
134+
135+
return $tab->add();
136+
}
115137
}

classes/Database/Uninstall.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
namespace PrestaShop\Module\Ps_Googleanalytics\Database;
2222

2323
use Db;
24+
use Tab;
2425

2526
class Uninstall
2627
{
@@ -42,4 +43,21 @@ public function uninstallTables()
4243

4344
return true;
4445
}
46+
47+
/**
48+
* uninstall tab
49+
*
50+
* @return bool
51+
*/
52+
public function uninstallTab()
53+
{
54+
$result = true;
55+
$id_tab = (int) Tab::getIdFromClassName('AdminGanalyticsAjax');
56+
$tab = new Tab($id_tab);
57+
if (Validate::isLoadedObject($tab)) {
58+
$result = $tab->delete();
59+
}
60+
61+
return $result;
62+
}
4563
}

classes/Hook/HookDisplayBeforeBodyClosingTag.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ public function run()
130130
$products = $productWrapper->wrapProductList(isset($listing['products']) ? $listing['products'] : []);
131131

132132
if ($controller_name == 'order' || $controller_name == 'orderopc') {
133-
$step = Tools::getValue('step');
134-
if (empty($step)) {
135-
$step = 0;
136-
}
137133
$eventData = [
138134
'currency' => $this->context->currency->iso_code,
139135
];

ps_googleanalytics.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public function install()
222222
return parent::install() &&
223223
$database->registerHooks() &&
224224
$database->setDefaultConfiguration() &&
225+
$database->installTab() &&
225226
$database->installTables();
226227
}
227228

@@ -236,6 +237,7 @@ public function uninstall()
236237
$database = new PrestaShop\Module\Ps_Googleanalytics\Database\Uninstall();
237238

238239
return parent::uninstall() &&
240+
$database->uninstallTab() &&
239241
$database->uninstallTables();
240242
}
241243

upgrade/upgrade-5.0.0.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
*/
2727
function upgrade_module_5_0_0($object)
2828
{
29+
$database = new PrestaShop\Module\Ps_Googleanalytics\Database\Install($object);
30+
2931
return
3032
Configuration::deleteByName('GA_V4_ENABLED') &&
3133
$object->registerHook('actionValidateOrder') &&
34+
$database->installTab() &&
3235
Configuration::updateValue('GA_BACKLOAD_ENABLED', false) &&
3336
Configuration::updateValue('GA_BACKLOAD_DAYS', 30);
3437
}

0 commit comments

Comments
 (0)