Bài hướng dẫn này dành cho các bạn sử dụng module tin tức được chia sẻ tại bài viết
http://hanamonline.com/module-tin-tuc-opencart/
Module tin tức này được chia sẻ trên opencartvn là module tin tức được nhiều bạn sử dụng nhất tuy nhiên một thiếu sót khá quan trọng của nó là không hỗ trợ sitemaps. Việc thêm url vào sitemaps và submit lên công cụ tìm kiếm giúp bài viết của bạn nhanh chóng được SE index.
Bạn cần sửa 2 file
+ Edit file /catalog/model/catalog/news.php
Thêm vào function
[php]
public function getNewIDs() {
$sql = "SELECT n.news_id FROM " . DB_PREFIX . "news n LEFT JOIN " . DB_PREFIX . "news_description nd ON (n.news_id = nd.news_id) LEFT JOIN " . DB_PREFIX . "news_to_store n2s ON (n.news_id = n2s.news_id) WHERE nd.language_id = ‘" . (int)$this->config->get(‘config_language_id’) . "’ AND n.status = ‘1’ AND n.date_available <= NOW() AND n2s.store_id = ‘" . (int)$this->config->get(‘config_store_id’) . "’";
$query = $this->db->query($sql);
return $query->rows;
}
[/php]
+ Edit file /catalog/controller/feed/google_sitemap.php
Tìm đoạn code
[php]
$output .= $this->getCategories(0);
$this->load->model(‘catalog/manufacturer’);
[/php]
Thêm vào sau nó đoạn code sau:
[php]
$this->load->model(‘catalog/news’);
$news = $this->model_catalog_news->getNewIDs();
foreach ($news as $new) {
$output .= ‘<url>’;
$output .= ‘<loc>’ . $this->url->link(‘news/news’, ‘&news_id=’ . $new[‘news_id’]) . ‘</loc>’;
$output .= ‘<changefreq>weekly</changefreq>’;
$output .= ‘<priority>1.0</priority>’;
$output .= ‘</url>’;
}
[/php]
OK vậy là xong rồi bạn nào cần thêm danh mục tin tức thì viết thêm mình ko SEO theo danh mục nên không thêm danh mục tin tức vào sitemap. Chúc các bạn thành công