context->shop->id; if ($link_rewrite) { $supplier = Tools::strtolower(str_replace('-', '%', $link_rewrite)); $sql = 'SELECT t1.id_supplier FROM ' . _DB_PREFIX_ . 'supplier t1 LEFT JOIN ' . _DB_PREFIX_ . 'supplier_shop t2 ON (t1.id_supplier = t2.id_supplier) WHERE t1.name LIKE (\'' . pSQL($supplier) . '\') AND t2.id_shop = ' . (int) $id_shop; $id_supplier = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_supplier != '') { $_POST['id_supplier'] = $id_supplier; $_GET['supplier_rewrite'] = ''; } } if (preg_match('/\?/', $_SERVER['REQUEST_URI'])) { $req_uri_qmark = explode('?', $_SERVER['REQUEST_URI']); $req_uri_without_qmark = $req_uri_qmark[0]; $req_uri_without_qmark = explode('/', $req_uri_without_qmark); $request = end($req_uri_without_qmark); $clearify_request = str_replace('-', ' ', $request); $supp_existance = (int) $this->getKeyExistanceSup($clearify_request); if ($supp_existance > 0) { $_POST['id_supplier'] = $supp_existance; } } // Fix for accented chars URLs $allow_accented_chars = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); if ($allow_accented_chars > 0) { $id_supplier = (int) Tools::getValue('id_supplier'); if ($id_supplier <= 0 && isset(Tools::getValue('supplier_rewrite'))) { $id = (int) $this->getKeyExistanceSup(Tools::getValue('supplier_rewrite')); if ($id > 0) { $_POST['id_supplier'] = $id; } } } parent::init(); } private function getKeyExistanceSup($request) { $sql = 'SELECT `id_supplier` FROM ' . _DB_PREFIX_ . 'supplier WHERE `name` LIKE "' . pSQL($request) . '"'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); } }