Advertisement
Guest User

Seo_urls

a guest
May 10th, 2013
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.55 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <modification>
  3.     <id>SEO - Custom url - adaptado de http://www.davidchc.com.br/tutoriais/opencart-tutoriais/transformando-as-outras-url-do-opencart-em-amigaveis/</id>
  4.     <version>1.0</version>
  5.     <vqmver>2.2.1</vqmver>
  6.     <author>jroqueweb</author>
  7.     <file name="catalog/controller/common/seo_url.php">
  8.         <operation>
  9.             <search position="before" index="1"><![CDATA[public function index() {]]></search>
  10.             <add><![CDATA[
  11.                private $urlFriendly = array(
  12.                    'common/home'       => 'home',
  13.                    'checkout/cart'     => 'carrinho',
  14.                    'account/register'  => 'cadastre-se',
  15.                    'account/wishlist'  => 'lista-de-desejo',
  16.                    'checkout/checkout' => 'checkout',
  17.                    'account/logout'    => 'sair',
  18.                    'account/login'     => 'login',
  19.                    'product/special'   => 'especial',
  20.                    'affiliate/account' => 'afiliado',
  21.                    'checkout/voucher'  => 'vale-presente',
  22.                    'product/manufacturer' => 'fabricante',
  23.                    'account/newsletter'   => 'newsletter',
  24.                    'account/order'        => 'meus-pedidos',
  25.                    'account/account'      => 'minha-conta',
  26.                    'information/contact'  => 'contato',
  27.                    'information/sitemap'   => 'mapa-do-site',
  28.                    'account/forgotten'     => 'lembrar-senha',
  29.                    'account/download'     => 'meus-download',
  30.                    'account/return'     => 'minhas-devolucoes',
  31.                    'account/transaction'     => 'minhas-indicacoes',
  32.                    'account/password'     => 'alterar-senha',
  33.                    'account/edit'     => 'alterar-informacoes',
  34.                    'account/address'     => 'alterar-enderecos',
  35.                    'account/reward'     => 'pontos-de-fidelidade',
  36.                );
  37.                
  38.                public function getKeyFriendly($_route) {
  39.                    if( count($this->urlFriendly) > 0 ){
  40.                        $key = array_search($_route, $this->urlFriendly);
  41.                        if($key && in_array($_route, $this->urlFriendly)){
  42.                            return $key;
  43.                        }
  44.                    }
  45.                    return false;
  46.                }
  47.  
  48.                public function getValueFriendly($route) {
  49.                    if( count($this->urlFriendly) > 0) {
  50.                        if(in_array($route, array_keys($this->urlFriendly))){
  51.                            return '/'.$this->urlFriendly[$route];
  52.                        }
  53.                    }
  54.                    return false;
  55.                }
  56.            ]]></add>
  57.         </operation>
  58.         <operation>
  59.             <search position="replace" offset="8"><![CDATA[if (isset($this->request->get['product_id'])) {]]></search>
  60.             <add><![CDATA[
  61.                if ($_key = $this->getKeyFriendly($this->request->get['_route_']) ) {
  62.                    $this->request->get['route'] = $_key;
  63.                }elseif (isset($this->request->get['product_id'])) {
  64.                    $this->request->get['route'] = 'product/product';
  65.                }elseif (isset($this->request->get['path'])) {
  66.                    $this->request->get['route'] = 'product/category';
  67.                } elseif (isset($this->request->get['manufacturer_id'])) {
  68.                    $this->request->get['route'] = 'product/manufacturer/product';
  69.                } elseif (isset($this->request->get['information_id'])) {
  70.                    $this->request->get['route'] = 'information/information';
  71.                }
  72.            ]]></add>
  73.         </operation>
  74.         <operation>
  75.             <search position="replace" offset="12"><![CDATA[} elseif ($key == 'path') {]]></search>
  76.             <add><![CDATA[
  77.                } elseif ($key == 'path') {
  78.                     $categories = explode('_', $value);
  79.                    
  80.                     foreach ($categories as $category) {
  81.                         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
  82.                
  83.                         if ($query->num_rows) {
  84.                             $url .= '/' . $query->row['keyword'];
  85.                         }                          
  86.                     }
  87.                    
  88.                     unset($data[$key]);
  89.                 }
  90.                if( $_link = $this->getValueFriendly($data['route']) ){
  91.                    $url .= $_link;
  92.                    unset($data[$key]);
  93.                }
  94.            ]]></add>
  95.         </operation>
  96.     </file>
  97. </modification>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement