OpenCart Change Pagination Links to SEO links OpenCart Change Pagination Links to SEO links nginx nginx

OpenCart Change Pagination Links to SEO links


I am assuming you have a .htaccess file setup and you are already using the SEO built into OpenCart 1.5. If not, here are some pretty good instructions: Adding SEO Friendly URL’S to OpenCart by Kevin Dees

This is a partial hack, but if all you want to fix is the pagination, it should work.

First you need to add 3 lines to the .htaccess file I referenced earlier. After this line:

RewriteRule sitemap.xml /index.php?route=feed/google_sitemap

Add:

RewriteCond %{QUERY_STRING} q=([^&]*) [OR]RewriteCond %{SCRIPT_FILENAME} .*search$RewriteRule search$ /index.php?route=product/search&filter_name=%1 [L,QSA]

So in all that section of the .htaccess file should look like:

RewriteBase /RewriteRule sitemap.xml /index.php?route=feed/google_sitemapRewriteCond %{QUERY_STRING} q=([^&]*) [OR]RewriteCond %{SCRIPT_FILENAME} .*search$RewriteRule search$ /index.php?route=product/search&filter_name=%1 [L,QSA]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Next you need to modify the /catalog/controller/product/search.php to generate the correct url. I commented out the line that generates the link and added my own 2 lines above it(you'll need replace http://www.example.com with your own info):

$pagination = new Pagination();$pagination->total = $product_total;$pagination->page = $page;$pagination->limit = $limit;$pagination->text = $this->language->get('text_pagination');$url = preg_replace("/filter_name/","q",$url);$pagination->url = "http://www.example.com/search?".$url."&page={page}";//$pagination->url = $this->url->link('product/search', $url . '&page={page}');$this->data['pagination'] = $pagination->render();

Resources: