File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222
2323use Configuration ;
2424use Db ;
25+ use Language ;
2526use Ps_Googleanalytics ;
2627use Shop ;
28+ use Tab ;
2729
2830class 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}
Original file line number Diff line number Diff line change 2121namespace PrestaShop \Module \Ps_Googleanalytics \Database ;
2222
2323use Db ;
24+ use Tab ;
2425
2526class 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}
Original file line number Diff line number Diff 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 ];
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 2626 */
2727function 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}
You can’t perform that action at this time.
0 commit comments