Good day community, I'm new at prestashop so I have a problem, I'm using prestahop 1.6.
I need to get the value of the url from a module.
The value I want to take is "category_rewrite" from the following ulr:
dominio.com/index.php?category_rewrite=ropa-dama&controller=category
Why to take this value, well I'm using the module to delete the IDs of the url, then the css class "active" of the menu stops working.
In the menu module I have the following function:
public function getCurrentCategoriesId($lang_id = NULL) {
if (isset($_GET['category_rewrite'])) {
$link_rewrite = $_GET['category_rewrite'];
$id_lang = $this->context->language->id;
$id_shop = $this->context->shop->id;
$sql = 'SELECT 'id_category'
FROM '._DB_PREFIX_.'category_lang
WHERE 'link_rewrite' = \''.pSQL($link_rewrite).'\'
AND 'id_lang' = '.(int)$id_lang.'
AND 'id_shop' = '.(int)$id_shop;
$id_category = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
} else {
$link_rewrite = false;
}
$lastCate = new Category((int) $id_category);
$parentCate = $lastCate->getParentsCategories($lang_id);
$arrayCateCurrent = array();
foreach ($parentCate as $pcate) {
$arrayCateCurrent[] = $pcate['id_category'];
}
return $arrayCateCurrent;
}
but I still do not get the value of the url, the original code is the following and it works correctly when I deactivate the urls module and the id is shown:
public function getCurrentCategoriesId($lang_id = NULL) {
if (isset($_GET['id_category'])) {
$lastCateId = $_GET['id_category'];
} else {
$lastCateId = 0;
}
$lastCate = new Category((int) $lastCateId);
//echo $lastCate->name[1]; echo '--------';
$parentCate = $lastCate->getParentsCategories($lang_id);
$arrayCateCurrent = array();
foreach ($parentCate as $pcate) {
$arrayCateCurrent[] = $pcate['id_category'];
}
return $arrayCateCurrent;
}
I hope you can help me, regards