Andrz2556 Posted May 3, 2024 Share Posted May 3, 2024 Hello, I did update the Prestashop to 1.7.8.11. and after it I have the issue when I want to open a category and a product. This the code what returns 'null' foreach ($languages AS $key => $lang) { if ($page == 'index') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getPageLink('index', true, $lang['id_lang']); } elseif ($page == 'product') { dump(Tools::getValue('id_product')); die; $array_of_links[$lang['language_code']]['url'] = $this->context->link->getProductLink(Tools::getValue('id_product'), null, null, null, $lang['id_lang']); } elseif ($page == 'category') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getCategoryLink(Tools::getValue('id_category'), null, $lang['id_lang']); } elseif ($page == 'manufacturer') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getManufacturerLink(Tools::getValue('id_manufacturer'), null, $lang['id_lang']); } elseif ($page == 'supplier') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getSupplierLink(Tools::getValue('id_supplier'), null, $lang['id_lang']); } elseif ($page == 'cms' && Tools::getValue('id_cms','false') != 'false') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getCmsLink(Tools::getValue('id_cms'), null, null, $lang['id_lang']); } elseif ($page == 'cms' && Tools::getValue('id_cms_category','false') != 'false') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getCmsCategoryLink(Tools::getValue('id_cms_category'), null, $lang['id_lang']); } elseif ($page == 'contact') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getPageLink('contact', null, $lang['id_lang']); } from myhreflang module. Like this code 'Tools::getValue('id_product') returns 'null'. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted May 3, 2024 Share Posted May 3, 2024 Please give more context about your module (type, on hook...). Link to comment Share on other sites More sharing options...
Andrz2556 Posted May 3, 2024 Author Share Posted May 3, 2024 3 minutes ago, Prestashop Addict said: Please give more context about your module (type, on hook...). This is the hook public function hookHeader($params) { $array_of_links[] = array(); if (isset($this->context->controller->php_self)) { $page = $this->context->controller->php_self; $languages = Language::getLanguages(false); foreach ($languages AS $key => $lang) { if ($page == 'index') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getPageLink('index', true, $lang['id_lang']); } elseif ($page == 'product') { // dump($_GET); // die; $array_of_links[$lang['language_code']]['url'] = $this->context->link->getProductLink(Tools::getValue('id_product'), null, null, null, $lang['id_lang']); } elseif ($page == 'category') { // dump($_GET); // die; $array_of_links[$lang['language_code']]['url'] = $this->context->link->getCategoryLink(Tools::getValue('id_category'), null, $lang['id_lang']); } elseif ($page == 'manufacturer') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getManufacturerLink(Tools::getValue('id_manufacturer'), null, $lang['id_lang']); } elseif ($page == 'supplier') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getSupplierLink(Tools::getValue('id_supplier'), null, $lang['id_lang']); } elseif ($page == 'cms' && Tools::getValue('id_cms','false') != 'false') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getCmsLink(Tools::getValue('id_cms'), null, null, $lang['id_lang']); } elseif ($page == 'cms' && Tools::getValue('id_cms_category','false') != 'false') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getCmsCategoryLink(Tools::getValue('id_cms_category'), null, $lang['id_lang']); } elseif ($page == 'contact') { $array_of_links[$lang['language_code']]['url'] = $this->context->link->getPageLink('contact', null, $lang['id_lang']); } if (isset($array_of_links[$lang['language_code']]['url'])) { $array_of_links[$lang['language_code']]['rel'] = 'alternate'; $array_of_links[$lang['language_code']]['hreflang'] = $lang['language_code']; if ($this->context->language->id == $lang['id_lang']) { $array_of_links['canonical']['url'] = $array_of_links[$lang['language_code']]['url']; $array_of_links['canonical']['rel'] = 'canonical'; $array_of_links['canonical']['hreflang'] = '-'; $array_of_links['xdefault']['url'] = $array_of_links[$lang['language_code']]['url']; $array_of_links['xdefault']['rel'] = 'alternate'; $array_of_links['xdefault']['hreflang'] = 'x-default'; } } } } if (count($array_of_links) > 0) { $this->context->smarty->assign('myhreflang', $array_of_links); return $this->display(__file__, 'views/hreflang.tpl'); } } Link to comment Share on other sites More sharing options...
Prestashop Addict Posted May 3, 2024 Share Posted May 3, 2024 Should work, can you try replace hookHeader (deprecated) by hookDisplayheader. Link to comment Share on other sites More sharing options...
Andrz2556 Posted May 3, 2024 Author Share Posted May 3, 2024 20 minutes ago, Prestashop Addict said: Should work, can you try replace hookHeader (deprecated) by hookDisplayheader. Changed and the the same error Link to comment Share on other sites More sharing options...
Prestashop Addict Posted May 3, 2024 Share Posted May 3, 2024 Strange. Can you place this code and test directly on 1rst line of your hook public function hookDisplayheader($params) { Tools::dieObject(Tools::getAllValues()); Link to comment Share on other sites More sharing options...
Andrz2556 Posted May 3, 2024 Author Share Posted May 3, 2024 7 minutes ago, Prestashop Addict said: Strange. Can you place this code and test directly on 1rst line of your hook public function hookDisplayheader($params) { Tools::dieObject(Tools::getAllValues()); array:3 [▼ "ars_rewrite_product" => "gas-and-wood-oven-70x75-manual-ignition" "fc" => "controller" "controller" => "product" ] END this what I get as the result Link to comment Share on other sites More sharing options...
Prestashop Addict Posted May 3, 2024 Share Posted May 3, 2024 (edited) You should obtain something like array:6 [▼ "isolang" => "fr" "id_lang" => 1 "id_product" => "3" "id_product_attribute" => "13" "rewrite" => "affiche-encadree-the-best-is-yet-to" "controller" => "product" ] It looks like you have a redirection, verify with other modules. Edited May 3, 2024 by Prestashop Addict (see edit history) Link to comment Share on other sites More sharing options...
Andrz2556 Posted May 3, 2024 Author Share Posted May 3, 2024 11 minutes ago, Prestashop Addict said: It looks like you have a redirection, verify with other modules. Maybe you have an example of what modules I need to check? Link to comment Share on other sites More sharing options...
Prestashop Addict Posted May 3, 2024 Share Posted May 3, 2024 il y a 4 minutes, Andrz2556 a dit : Maybe you have an example of what modules I need to check? Search in php code something like Tools::redirect or header('Location: Link to comment Share on other sites More sharing options...
Andrz2556 Posted May 3, 2024 Author Share Posted May 3, 2024 14 minutes ago, Prestashop Addict said: Search in php code something like Tools::redirect or header('Location: I found a lot of things (Tools::redirect) like that, but about what exactly I need to change Link to comment Share on other sites More sharing options...
Andrz2556 Posted May 3, 2024 Author Share Posted May 3, 2024 33 minutes ago, Prestashop Addict said: Search in php code something like Tools::redirect or header('Location: I found where the issue but I have now, such results array:2 [▼ "rewrite" => "gas-and-wood-oven-70x75-manual-ignition" "controller" => "product" ] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now