In order to setup an A/B testing (through GG Analytics), I planned to duplicate my current theme (for organisations purposes) in order to use the duplicated theme to do the alternate versions of the test. I use Prestashop 1.4.9.2
.
What I already did, and works:
Added this to /classes/FrontController.php
, in displayHeader()
function (I know I should override, but not the point ;)):
if(isset($_GET['alternate']))
{
$cookie->alternate = "1";
$cookie->write();
}
Replaced in /config/settings.inc.php
:
define('_THEME_NAME_', 'my_usual_theme');
by
if(isset($_GET['alternate']) || $cookie->alternate == "1")
{
define('_THEME_NAME_', 'my_alternate_theme');
}
else
{
define('_THEME_NAME_', 'my_usual_theme');
}
This way, when I load my Prestahop url with "?alternate
" at the end, it loads the alternative theme. Fine.
PROBLEM: I can't check the cookie value in settings.inc.php
, and so when I click a link, it loads the default theme.
QUESTION:
Any clue to check the cookie in this file ? Or config.inc.php
? Or "re-define" the theme name in another file, overriding the settings.inc.php
setup ?
Please note I check the cookie in another single file to validate the process, and it works well. I also tried to use classic setcookie
method, but if I can read/check, I can't write with this way... And for a reason I don't get, PHP activation in Smarty just don't work (tried to setcookie
directly in template, but error 500 even with a simple echo).
Thanks.