Test with only site language latin...
Replace file admin/model/tool/seo_url.php with this code
then add a product or update a product, the site autoupdate all link on your site
Good luck!
demo: http://f2laptop.com.vn
Code: Select all
<?php
function sanitize_title($title) {
// Preserve escaped octets.
$title=preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|','---$1---',$title);
// Remove percent signs that are not part of an octet.
$title=str_replace('%','',$title);
// Restore octets.
$title=preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|','%$1',$title);
$title=strtolower($title);
$title=preg_replace('/&.+?;/','',$title);
// kill entities
$title=preg_replace('/[^%a-z0-9 _-]/','',$title);
$title=preg_replace('/\s+/','-',$title);
$title=preg_replace('|-+|','-',$title);
$title=trim($title,'-');
return $title;
}
class ModelToolSeoUrl extends Model {
public function generate() {
$this->db->query("TRUNCATE TABLE `".DB_PREFIX."url_alias`");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=common/home', `alias` = ''");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=product/special', `alias` = 'special.html'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=account/account', `alias` = 'account.html'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=account/create', `alias` = 'create.html'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=product/latest', `alias` = 'latest.html'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=account/login', `alias` = 'login.html'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=account/logout', `alias` = 'logout.html'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=checkout/cart', `alias` = 'cart.html'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=checkout/shipping', `alias` = 'shipping'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=information/contact', `alias` = 'contact.html'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=information/sitemap', `alias` = 'sitemap.html'");
$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET `query` = 'route=product/search', `alias` = 'search.html'");
// Product
$product_query=$this->db->query("SELECT * FROM ".DB_PREFIX."product_description");
foreach($product_query->rows as $product) {
if($product['name']) {
$seoalias=sanitize_title($product['name']."-".$product['product_id']).".html";
$this->db->query("INSERT INTO ".DB_PREFIX."url_alias SET `query` = 'route=product/product&product_id=".(int) $product['product_id']."', `alias` = '$seoalias'");
}
}
// Category /
$this->categories(0);
// Manufacturer
$manufacturer_query=$this->db->query("SELECT * FROM ".DB_PREFIX."manufacturer");
foreach($manufacturer_query->rows as $manufacturer) {
if($manufacturer['keyword']) {
$this->db->query("INSERT INTO ".DB_PREFIX."url_alias SET `query` = 'route=product/manufacturer&manufacturer_id=".(int) $manufacturer['manufacturer_id']."', `alias` = '".$this->db->escape($manufacturer['keyword']).".html'");
}
$product_query=$this->db->query("SELECT * FROM ".DB_PREFIX."product WHERE manufacturer_id = '".(int) $manufacturer['manufacturer_id']."'");
foreach($product_query->rows as $product) {
if(($manufacturer['keyword'])&&($product['keyword'])) {
$this->db->query("INSERT INTO ".DB_PREFIX."url_alias SET `query` = 'route=product/product&manufacturer_id=".(int) $manufacturer['manufacturer_id']."&product_id=".(int) $product['product_id']."', `alias` = '".$this->db->escape($manufacturer['keyword'].'/'.$product['keyword']).".html'");
}
}
}
// Information
$information_query=$this->db->query("SELECT * FROM ".DB_PREFIX."information");
foreach($information_query->rows as $information) {
if($information['keyword']) {
$this->db->query("INSERT INTO ".DB_PREFIX."url_alias SET `query` = 'route=information/information&information_id=".(int) $information['information_id']."', `alias` = '".$this->db->escape($information['keyword']).".html'");
}
}
}
private function categories($path) {
$keyword='';
$parts=explode('_',$path);
foreach($parts as $category_id) {
$category_query=$this->db->query("SELECT * FROM ".DB_PREFIX."category_description WHERE category_id = '".(int) $category_id."'");
if($category_query->num_rows) {
$keyword.=$category_query->row['name'].'/';
}
}
$category_id=array_pop($parts);
$category_query=$this->db->query("SELECT * FROM ".DB_PREFIX."category_description a LEFT JOIN ".DB_PREFIX."category b ON (a.category_id = b.category_id) WHERE parent_id = '".(int) $category_id."'");
foreach($category_query->rows as $category) {
if(!$path) {
$new_path=$category['category_id'];
}
else{
$new_path=$path.'_'.$category['category_id'];
}
if($category['name']) {
$seoalias=sanitize_title($keyword."-".$category['name']).".html";
$this->db->query("INSERT INTO ".DB_PREFIX."url_alias SET `query` = 'route=product/category&path=".$this->db->escape($new_path)."', `alias` = '$seoalias'");
}
$product_query=$this->db->query("SELECT * FROM ".DB_PREFIX."product_description p LEFT JOIN ".DB_PREFIX."product_to_category p2c ON (p.product_id = p2c.product_id) WHERE p2c.category_id = '".(int) $category['category_id']."'");
foreach($product_query->rows as $product) {
if(($category['name'])&&($product['name'])) {
$seoalias=sanitize_title($keyword."-".$category['name']."-".$product['name']."-".$product['product_id']).".html";
$this->db->query("INSERT INTO ".DB_PREFIX."url_alias SET `query` = 'route=product/product&path=".$this->db->escape($new_path)."&product_id=".(int) $product['product_id']."', `alias` = '$seoalias'");
}
}
$this->categories($new_path);
}
}
}
?>