I have check and fix the problem, now the code tested on OPENCART 2.0.0.0 (1st Oct 2014)
The real code is not created by me, i'm just fix this.
BACKUP YOUR FILE BEFORE DO THIS.
1. Go to /public_html/catalog/controller/common/ and find seo_url.php then change the code with this one:2. Open your PHP My Admin, and add this one to your SQL:Code: Select all
<?php class ControllerCommonSeoUrl extends Controller { public function index() { // Add rewrite to url class if ($this->config->get('config_seo_url')) { $this->url->addRewrite($this); } // Decode URL if (isset($this->request->get['_route_'])) { $parts = explode('/', $this->request->get['_route_']); $route = ""; foreach ($parts as $part) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'"); if ($query->num_rows) { $url = explode('=', $query->row['query']); if(count($url) > 1){ if ($url[0] == 'product_id') { $this->request->get['product_id'] = $url[1]; } if ($url[0] == 'category_id') { if (!isset($this->request->get['path'])) { $this->request->get['path'] = $url[1]; } else { $this->request->get['path'] .= '_' . $url[1]; } } if ($url[0] == 'manufacturer_id') { $this->request->get['manufacturer_id'] = $url[1]; } if ($url[0] == 'information_id') { $this->request->get['information_id'] = $url[1]; } }else{ $route = $url[0]; } } else { $this->request->get['route'] = 'error/not_found'; } } if (isset($this->request->get['product_id'])) { $this->request->get['route'] = 'product/product'; } elseif (isset($this->request->get['path'])) { $this->request->get['route'] = 'product/category'; } elseif (isset($this->request->get['manufacturer_id'])) { $this->request->get['route'] = 'product/manufacturer/product'; } elseif (isset($this->request->get['information_id'])) { $this->request->get['route'] = 'information/information'; }else { $this->request->get['route'] = $route; } if (isset($this->request->get['route'])) { return new Action($this->request->get['route']); } } } public function rewrite($link) { if ($this->config->get('config_seo_url')) { $url_data = parse_url(str_replace('&', '&', $link)); $url = ''; $data = array(); parse_str($url_data['query'], $data); foreach ($data as $key => $value) { if (($key == 'product_id') || ($key == 'manufacturer_id') || ($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) { $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) { $url .= '/' . $query->row['keyword']; } } unset($data[$key]); }elseif ($key == 'route') { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($value) . "'"); if ($query->num_rows) { $url .= '/' . $query->row['keyword']; unset($data[$key]); } } } if ($url) { unset($data['route']); $query = ''; if ($data) { foreach ($data as $key => $value) { $query .= '&' . $key . '=' . $value; } if ($query) { $query = '?' . trim($query, '&'); } } return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query; } else { return $link; } } else { return $link; } } } ?>
Code: Select all
INSERT INTO url_alias (query, keyword) VALUES ('common/home', ''); INSERT INTO url_alias (query, keyword) VALUES ('account/wishlist', 'wishlist'); INSERT INTO url_alias (query, keyword) VALUES ('account/account', 'my-account'); INSERT INTO url_alias (query, keyword) VALUES ('checkout/cart', 'shopping-cart'); INSERT INTO url_alias (query, keyword) VALUES ('checkout/checkout', 'checkout'); INSERT INTO url_alias (query, keyword) VALUES ('account/login', 'login'); INSERT INTO url_alias (query, keyword) VALUES ('account/logout', 'logout'); INSERT INTO url_alias (query, keyword) VALUES ('account/order', 'order-history'); INSERT INTO url_alias (query, keyword) VALUES ('account/newsletter', 'newsletter'); INSERT INTO url_alias (query, keyword) VALUES ('product/special', 'specials'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/account', 'affiliates'); INSERT INTO url_alias (query, keyword) VALUES ('checkout/voucher', 'gift-vouchers'); INSERT INTO url_alias (query, keyword) VALUES ('product/manufacturer', 'brands'); INSERT INTO url_alias (query, keyword) VALUES ('information/contact', 'contact-us'); INSERT INTO url_alias (query, keyword) VALUES ('account/return/insert', 'request-return'); INSERT INTO url_alias (query, keyword) VALUES ('information/sitemap', 'sitemap'); INSERT INTO url_alias (query, keyword) VALUES ('account/forgotten', 'forgot-password'); INSERT INTO url_alias (query, keyword) VALUES ('account/download', 'downloads'); INSERT INTO url_alias (query, keyword) VALUES ('account/return', 'returns'); INSERT INTO url_alias (query, keyword) VALUES ('account/transaction', 'transactions'); INSERT INTO url_alias (query, keyword) VALUES ('account/register', ''register'); INSERT INTO url_alias (query, keyword) VALUES ('account/recurring', ''recurring'); INSERT INTO url_alias (query, keyword) VALUES ('product/compare', 'compare-products'); INSERT INTO url_alias (query, keyword) VALUES ('product/search', 'search'); INSERT INTO url_alias (query, keyword) VALUES ('account/edit', 'edit-account'); INSERT INTO url_alias (query, keyword) VALUES ('account/password', 'change-password'); INSERT INTO url_alias (query, keyword) VALUES ('account/address', 'address-book'); INSERT INTO url_alias (query, keyword) VALUES ('account/reward', 'reward-points'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/edit', 'edit-affiliate-account'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/password', 'change-affiliate-password'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/payment', 'affiliate-payment-options'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/tracking', 'affiliate-tracking-code'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/transaction', 'affiliate-transactions'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/logout', 'affiliate-logout'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/forgotten', 'affiliate-forgot-password'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/register', 'create-affiliate-account'); INSERT INTO url_alias (query, keyword) VALUES ('affiliate/login', 'affiliate-login');
If there any problems/bug i can't fix that or maybe i can just try it! i hope this code is work.What's changed?
- added new link (for Recurring Payments link)
- edit 'line 64' with default code in Opencart 2.0.0.0
i'm newbie in coding, but if this code work for Opencart 2.0.0.0 i will proud for myself.
-Sorry for my bad english, because i'm Indonesian.