mareksmareks Posted January 2, 2015 Share Posted January 2, 2015 Hi. I have installed version 1.4.11 When you search product in backoffice prestashop gives you product and 2 availabe actions to operate - edit product and delete it. I wanted to create one more shortcut to selling stats of this product. So I opened admin/tabs/AdminSearch and added code like this: <a href="'.$currentIndex.'?tab=AdminStats&module=statsproduct&id_product='.$product['id_product'].'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'"> Button show up and shortcut is correct but before taking me to this selling page Chrome gives me Token error, so i have to skip this warning and then i can see my stats. How could I fix this? Thank you! Link to comment Share on other sites More sharing options...
mareksmareks Posted January 3, 2015 Author Share Posted January 3, 2015 nobody? Link to comment Share on other sites More sharing options...
vblanch Posted January 4, 2015 Share Posted January 4, 2015 nobody? Hi there, first of all... do you really need to install 1.4? It's a very outdated version, better use 1.6 if you can! Second, the token doesn't work the same way in PS1.4, I have the code somewhere and I can post it here but as I said before, you better move to 1.6, because you will lack support for that version in the future. Cheers. Link to comment Share on other sites More sharing options...
mareksmareks Posted January 5, 2015 Author Share Posted January 5, 2015 Hi, im using 1.4.11 because I have been using it since it was latest version and right now we dont want to upgrade beacause we have few custom changes in template. We tried to upgrade on test site, but there was some problems with old/new image display system. For some reason pictures in upgraded version was not showing up. Link to comment Share on other sites More sharing options...
vblanch Posted January 5, 2015 Share Posted January 5, 2015 (edited) Hi, im using 1.4.11 because I have been using it since it was latest version and right now we dont want to upgrade beacause we have few custom changes in template. We tried to upgrade on test site, but there was some problems with old/new image display system. For some reason pictures in upgraded version was not showing up. I can copypaste the code that I have, hope it helps: if (_PS_VERSION_ < '1.5'){ global $currentIndex; $className = 'AdminModules'; $token = Tools::getAdminToken($className.intval(Tab::getIdFromClassName($className)).intval($this->context->cookie->id_employee)); $adminlink = $currentIndex.'&token='.$token;//.'index.php?tab=AdminModules'; $token_products = Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($this->context->cookie->id_employee)); }else{ $adminlink = $this->context->link->getAdminLink('AdminModules'); $token_products = Tools::getAdminToken('AdminProducts'.intval(Tab::getIdFromClassName('AdminProducts')).intval($this->context->cookie->id_employee)); } This should get the correct token for the product catalog. Then in the TPL I have: {if version_compare($smarty.const._PS_VERSION_,'1.5','>=')} <td><a class="button" href="index.php?controller=AdminProducts&id_product={$product['id_product']}&updateproduct&token={$token_products}" target="_blank"">{l s='Edit' mod='yourmodule'}</td> {else} <td><a class="button" href="index.php?tab=AdminCatalog&id_product={$product['id_product']}&updateproduct&token={$token_products}" target="_blank"">{l s='Edit' mod='yourmodule'}</td> {/if} Hope it helps! Edited January 5, 2015 by vblanch (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts