今天用opencart建站,发现opencart对SEO的问题,发现有3个是需要对opencart二次开发的.
第一:产品URL带有父类的URL,这样会出现过多的重复页;
第二:产品添加的时候如果SEOKEY不填写则会以动态形式写入;
第三:分类和第二个一样,必须填写SEOKEY.
耐何上传产品的小妹妹不懂啥叫SEO,对网站的认识也比较少,自己辛苦下,进行下开发: 请确保后台开启了高级URL Rewrite’s(伪静态)
先说第一点:针对opencart去除父类url的方法:
前台控制器里的common的核心里有个seo_url.php
foreach ($data as $key => $value) {
if (isset($data[‘route’])) {
if (($data[‘route’] == ‘product/product’ && $key == ‘product_id’) || (($data[‘route’] == ‘product/manufacturer/info’ || $data[‘route’] == ‘product/product’) && $key == ‘manufacturer_id’) || ($data[‘route’] == ‘information/information’ && $key == ‘information_id’)) {
$query = $this->db->query(“SELECT * FROM ” . DB_PREFIX . “url_alias WHERE `query` = ‘” . $this->db->escape($key . ‘=’ . (int)$value) . “‘”);
if ($query->num_rows && $query->row[‘keyword’]) {
//$url .= ‘/’ . $query->row[‘keyword’];
$url = ‘/’ . $query->row[‘keyword’];
unset($data[$key]);
}
} elseif ($key == ‘path’) {
$categories = explode(‘_’, $value);
foreach ($categories as $category) {
$query = $this->db->query(“SELECT * FROM ” . DB_PREFIX . “url_alias WHERE `query` = ‘category_id=” . (int)$category . “‘”);
if ($query->num_rows && $query->row[‘keyword’]) {
//$url .= ‘/’ . $query->row[‘keyword’];
$url = ‘/’ . $query->row[‘keyword’];
} else {
$url = ”;
break;
}
}
unset($data[$key]);
}
}
}
关于作者