Opencart 2.2 Canonical Url Hakkında yardım
3
●395
- 04-10-2017, 18:52:43canonical yapıya donusturmeniz icin biraz php bilginiz olması gerekmektedir. aslında ucretsiz yardımı olmaz kolay degildir. ama ben size buraya bir vqmod birakayım.burdaki islemleri tek tek yapabilirseniz sorununuz cozulecektir.
<file name="catalog/model/catalog/product.php"> <operation> <search position="before" offset="1"><![CDATA[ public function getTotalProductSpecials() {]]></search> <add><![CDATA[ public function getCategoryPath($product_id) { $query = $this->db->query("SELECT category_id AS catid FROM " . DB_PREFIX . "category WHERE category_id IN (SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "' ) ORDER BY sort_order asc LIMIT 1"); if(array_key_exists('catid', $query->row)) { $path = array(); $path[0] = $query->row['catid']; $query = $this->db->query("SELECT parent_id AS pid FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$path[0] . "'"); $parent = $query->row['pid']; $p = 1; while($parent>0){ $path[$p] = $parent; $query = $this->db->query("SELECT parent_id AS pid FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$parent . "'"); $parent = $query->row['pid']; $p++; } $path = array_reverse($path); $fullpath = ''; foreach($path as $val){ $fullpath .= '_'.$val; } return ltrim($fullpath, '_'); }else{ return '0'; } } ]]></add> </operation> </file> <file name="catalog/model/catalog/category.php"> <operation> <search position="before" offset="1"><![CDATA[ public function getTotalCategoriesByCategoryId($parent_id = 0) {]]></search> <add><![CDATA[ public function getCategoryPath($category_id){ $path = ''; $category = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c WHERE c.category_id = " .(int)($category_id)); if($category->row['parent_id'] != 0){ $path .= $this->getCategoryPath($category->row['parent_id']) . '_'; } $path .= $category->row['category_id']; return $path; } ]]></add> </operation> </file> <file name="catalog/controller/product/product.php"> <operation> <search position="replace"><![CDATA[$this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');]]></search> <add><![CDATA[if($this->model_catalog_product->getCategoryPath($this->request->get['product_id'])!='0'){ $this->document->addLink($this->url->link('product/product', 'path=' . $this->model_catalog_product->getCategoryPath($this->request->get['product_id']) . '&product_id=' . $this->request->get['product_id']), 'canonical'); } else{ $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical'); }]]></add> </operation> </file> <file name="catalog/controller/product/category.php"> <operation> <search position="replace" offset="8"><![CDATA[// http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html]]></search> <add><![CDATA[ $this->document->addLink($this->url->link('product/category', 'path=' . $this->model_catalog_category->getCategoryPath($category_id)), 'canonical'); ]]></add> </operation> </file> <file name="catalog/controller/common/home.php"> <operation> <search position="after"><![CDATA[ $this->document->setDescription($this->config->get('config_meta_description')); ]]></search> <add><![CDATA[ $this->document->addLink( $this->url->link('common/home') , 'canonical'); ]]></add> </operation> </file> <file name="system/library/response.php"> <operation> <search position="after"><![CDATA[ public function output() { ]]></search> <add><![CDATA[ if (!defined('HTTP_CATALOG')) $this->output = str_replace('index.php?route=common/home', '', $this->output); ]]></add> </operation> </file> - 05-10-2017, 14:50:09Misafir adlı üyeden alıntı: mesajı görüntüle
Hocam ilginiz için teşekür ederim. Keşke bu kodları hangi dosyalara koyacağımıda belirtseydiniz. - 05-10-2017, 15:59:11iste vqmod dosyası dedim ama bakın anlamamışsınız ,
<file name="catalog/model/catalog/product.php">
bu kısımda sana diyorki bu dosyayı ac.
bu kısımdada<search position="before" offset="1"><![CDATA[ public function getTotalProductSpecials() {]]></search>kod kısmını bul oncesine ekle altındaki kod dagarcigini.
bilginiz yoksa hic ellemeyin ucretli yardım talebinde bulunun derim.