Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <modification>
- <id>SEO - Custom url - adaptado de http://www.davidchc.com.br/tutoriais/opencart-tutoriais/transformando-as-outras-url-do-opencart-em-amigaveis/</id>
- <version>1.0</version>
- <vqmver>2.2.1</vqmver>
- <author>jroqueweb</author>
- <file name="catalog/controller/common/seo_url.php">
- <operation>
- <search position="before" index="1"><![CDATA[public function index() {]]></search>
- <add><![CDATA[
- private $urlFriendly = array(
- 'common/home' => 'home',
- 'checkout/cart' => 'carrinho',
- 'account/register' => 'cadastre-se',
- 'account/wishlist' => 'lista-de-desejo',
- 'checkout/checkout' => 'checkout',
- 'account/logout' => 'sair',
- 'account/login' => 'login',
- 'product/special' => 'especial',
- 'affiliate/account' => 'afiliado',
- 'checkout/voucher' => 'vale-presente',
- 'product/manufacturer' => 'fabricante',
- 'account/newsletter' => 'newsletter',
- 'account/order' => 'meus-pedidos',
- 'account/account' => 'minha-conta',
- 'information/contact' => 'contato',
- 'information/sitemap' => 'mapa-do-site',
- 'account/forgotten' => 'lembrar-senha',
- 'account/download' => 'meus-download',
- 'account/return' => 'minhas-devolucoes',
- 'account/transaction' => 'minhas-indicacoes',
- 'account/password' => 'alterar-senha',
- 'account/edit' => 'alterar-informacoes',
- 'account/address' => 'alterar-enderecos',
- 'account/reward' => 'pontos-de-fidelidade',
- );
- public function getKeyFriendly($_route) {
- if( count($this->urlFriendly) > 0 ){
- $key = array_search($_route, $this->urlFriendly);
- if($key && in_array($_route, $this->urlFriendly)){
- return $key;
- }
- }
- return false;
- }
- public function getValueFriendly($route) {
- if( count($this->urlFriendly) > 0) {
- if(in_array($route, array_keys($this->urlFriendly))){
- return '/'.$this->urlFriendly[$route];
- }
- }
- return false;
- }
- ]]></add>
- </operation>
- <operation>
- <search position="replace" offset="8"><![CDATA[if (isset($this->request->get['product_id'])) {]]></search>
- <add><![CDATA[
- if ($_key = $this->getKeyFriendly($this->request->get['_route_']) ) {
- $this->request->get['route'] = $_key;
- }elseif (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';
- }
- ]]></add>
- </operation>
- <operation>
- <search position="replace" offset="12"><![CDATA[} elseif ($key == 'path') {]]></search>
- <add><![CDATA[
- } 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]);
- }
- if( $_link = $this->getValueFriendly($data['route']) ){
- $url .= $_link;
- unset($data[$key]);
- }
- ]]></add>
- </operation>
- </file>
- </modification>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement