Hello! If you came to this page, most likely you have an online store on opencart, and it has a blog module installed namely Pav Blog, and it does not work Seo User Friendly URL articles, categories, well, or you just plan to put it ...
This blog module for opencart is very common and good to use, but it has a small drawback that there is no SEO support for ocstore assemblies or other assemblies in which SeoPro is connected, or rather it's not even a disadvantage that the module's author did seo support for the standard opencart.
If your online store works with SeoPro enabled, then you need to correct the SeoPro file to improve the User Friendly URL of your blog links.
There is nothing complicated here, but as always be careful and make backups just in case.
Well, let's get down to our task and make proper cc links for the blog.
The first thing we need to do is add two new lines to the table in the oc_url_alias table, namely, execute the query:
1 2 |
INSERT INTO url_alias (query, keyword) VALUES ('pavblog/blogs', 'blog'); INSERT INTO url_alias (query, keyword) VALUES ('pavblog/category=1', 'blog'); |
well, or if you have any Seo manager installed, then you can add these lines through them, common in the table, you should see these lines:
That is, for the category ID=1 and for the blog itself we add the blog key (PS: instead of the blog you can specify any other value of your own)
well, we finished the table, now let's edit the SeoPro file itself, for this we open it at catalog/controller/common/seo_pro.php with your favorite notepad, (recommend notepad +) and make small changes in it.
Before the line:
1 |
if (isset($queries[$parts[0]])) { |
We need to add:
1 2 3 4 5 6 7 8 9 |
/* SEO web-ukraine.com PAV BLOG START */ if( isset($url) && count($url) == 2 && ( preg_match( "#pavblog#", $url[0] )) ){ unset($this->request->get['pavblog/category']); unset($this->request->get['pavblog/blog']); unset($queries); $this->request->get['route'] = $url[0]; $this->request->get['id'] = $url[1]; } /* SEO web-ukraine.com PAV BLOG STOP */ |
Next we find the line of code:
1 |
case 'product/product/review': |
And before it we add:
1 2 3 4 5 6 7 |
// SEO web-ukraine.com PAV BLOG START case 'pavblog/category': break; case 'pavblog/blog': $isblog = 1; break; // SEO web-ukraine.com PAV BLOG STOP |
In the SWITCH cycle below the line:
1 |
switch ($key) { |
We are looking for default: and before it we add:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
// SEO web-ukraine.com PAV BLOG START case 'id': if(isset($isblog)){ if ($this->config->get('config_seo_url_include_path')) { $blogpath = $this->getPathByBlog($value); if($blogpath){ $categories = explode('_', $blogpath); foreach ($categories as $category) { $queries[] = 'pavblog/category=' . $category; } } } $queries[] = 'pavblog/blog=' . $value; $postfix = 1; }else{ $category = $value; $blogpath = $this->getPathByBlogCat($category); if($blogpath){ $categories = explode('_', $blogpath); foreach ($categories as $category) { $queries[] = 'pavblog/category=' . $category; } } } unset($data[$key]); break; // SEO web-ukraine.com PAV BLOG STOP |
Next we find the row with the code:
1 |
private function getPathByProduct($product_id) { |
And before it we add:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
// SEO web-ukraine.com PAV BLOG START private function getPathByBlog($blog_id) { $blog_id = (int)$blog_id; if ($blog_id < 1) return false; static $path = null; if (!is_array($path)) { $path = $this->cache->get('blog.seopath'); if (!is_array($path)) $path = array(); } if (!isset($path[$blog_id])) { $query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "pavblog_blog WHERE blog_id = '" . $blog_id . "' ORDER BY category_id DESC LIMIT 1"); $path[$blog_id] = $this->getPathByBlogCat($query->num_rows ? (int)$query->row['category_id'] : 0); $this->cache->set('blog.seopath', $path); } return $path[$blog_id]; } private function getPathByBlogCat($category_id) { $category_id = (int)$category_id; if ($category_id < 1) return false; static $path = null; if (!is_array($path)) { $path = $this->cache->get('blogcat.seopath'); if (!is_array($path)) $path = array(); } if (!isset($path[$category_id])) { $max_level = 2; $sql = "SELECT CONCAT_WS('_'"; for ($i = $max_level-1; $i >= 0; --$i) { $sql .= ",t$i.category_id"; } $sql .= ") AS path FROM " . DB_PREFIX . "pavblog_category t0"; for ($i = 1; $i < $max_level; ++$i) { $sql .= " LEFT JOIN " . DB_PREFIX . "pavblog_category t$i ON (t$i.category_id = t" . ($i-1) . ".parent_id)"; } $sql .= " WHERE t0.category_id = '" . $category_id . "'"; $query = $this->db->query($sql); $path[$category_id] = $query->num_rows ? $query->row['path'] : false; $this->cache->set('blogcat.seopath', $path); } return $path[$category_id]; } // SEO web-ukraine.com PAV BLOG STOP |
Well, in principle, that's all, now in our folder you can see the seo pages that you registered in the admin panel.
Oh, and do not forget to clear the cache to see the changes you made.
The blog module for opencart you can
Or download from our server here< There will be questions or something that does not work write in the comments, good luck!
No Comment
You can post first response comment.