Добрый день всем!
Уже не раз обсуждался крупный недостаток в OpenCart для SEO специалистов - это отсутствие возможности настроить самому содержимое тэгов TITLE и H1.
Довольно серьёзная причина почему многие SEO специалисты отказывались работать с ней.
По моему заданию это было исправлено и работает - если поля TITLE и H1 не заполнены то значения берутся как раньше из названия товара, а если заполнены то из заполненных значений. Теперь выкладываю БЕСПЛАТНО на всеобщее обозрение, надеюсь babushka и те кто отвечают за обновление русского OpenCart. добавят это в русскую сборку.
Кодер буржуйский, поэтому комменты на английском:
Added two fields in tables :
1. oc_product_description
2. oc_category_description
meta_title
h1tag
Changes :
admin/view/template/catalog/category_form.tpl
44 line to line 54
_______Added _______<tr> <td>Meta Title</td> <td><input name="category_description[<?php echo $language['language_id']; ?>][meta_title]" size="100" value="<?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['meta_title'] : ''; ?>" /> </td> </tr> <tr> <td>H1 tag</td> <td><input name="category_description[<?php echo $language['language_id']; ?>][h1tag]" size="100" value="<?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['h1tag'] : ''; ?>" /> </td> </tr>_______Added____
admin/view/template/catalog/product_form.tpl
44 line to line 57
_______Added _______<tr> <td>Meta Title</td> <td> <input type="text" name="product_description[<?php echo $language['language_id']; ?>][meta_title]" value="<?php echo isset($product_description[$language['language_id']]) ? $product_description[$language['language_id']]['meta_title'] : ''; ?>" size="80"/> </td> </tr> <tr> <td>H1 tag</td> <td> <input type="text" name="product_description[<?php echo $language['language_id']; ?>][h1tag]" value="<?php echo isset($product_description[$language['language_id']]) ? $product_description[$language['language_id']]['h1tag'] : ''; ?>" size="80"/> </td> </tr>_______Added____
admin/model/catalog/category.php
Line 12 - changed from
foreach ($data['category_description'] as $language_id => $value) { $this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "'"); }
To
foreach ($data['category_description'] as $language_id => $value) { $this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', h1tag = '" . $this->db->escape($value['h1tag']) . "'"); }
Line 38 From
foreach ($data['category_description'] as $language_id => $value) { $this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "'"); }
To
foreach ($data['category_description'] as $language_id => $value) { $this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', h1tag = '" . $this->db->escape($value['h1tag']) . "'"); }
Line 123 From
$category_description_data[$result['language_id']] = array( 'name' => $result['name'], 'meta_keywords' => $result['meta_keywords'], 'meta_description' => $result['meta_description'], 'description' => $result['description'] );
To
$category_description_data[$result['language_id']] = array( 'name' => $result['name'], 'meta_keywords' => $result['meta_keywords'], 'meta_description' => $result['meta_description'], 'description' => $result['description'], 'meta_title' => $result['meta_title'], 'h1tag' => $result['h1tag'] );
admin/model/catalog/product.php
Line 12 From
foreach ($data['product_description'] as $language_id => $value) { $this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "'"); }
To
foreach ($data['product_description'] as $language_id => $value) { $this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', h1tag = '" . $this->db->escape($value['h1tag']) . "'"); }
Line 107 From
foreach ($data['product_description'] as $language_id => $value) { $this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "'"); }
To
foreach ($data['product_description'] as $language_id => $value) { $this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', meta_keywords = '" . $this->db->escape($value['meta_keywords']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', h1tag = '" . $this->db->escape($value['h1tag']) . "'"); }
Line 388 From
$product_description_data[$result['language_id']] = array( 'name' => $result['name'], 'meta_keywords' => $result['meta_keywords'], 'meta_description' => $result['meta_description'], 'description' => $result['description'] );
To
$product_description_data[$result['language_id']] = array( 'name' => $result['name'], 'meta_keywords' => $result['meta_keywords'], 'meta_description' => $result['meta_description'], 'description' => $result['description'], 'meta_title' => $result['meta_title'], 'h1tag' => $result['h1tag'] );
catalog/controller/product/category.php
Line 48 from
$this->document->title = $category_info['name'];
To
if($category_info['meta_title'] == "") { $this->document->title = $category_info['name']; } else { $this->document->title = $category_info['meta_title']; }
catalog/controller/product/product.php
Line 113 from
$this->document->title = $product_info['name'];
To
if($product_info['meta_title'] == "") { $this->document->title = $product_info['name']; } else { $this->document->title = $product_info['meta_title']; }