Answer the question
In order to leave comments, you need to log in
Automatic meta tags?
Who knows how to auto-generate meta tags in opencart?
It is necessary according to the principle "Buy 'Product Name' in Moscow"
But I need to save those meta tags that are already registered. And for the rest, set according to the template.
Thanks in advance for your replies.
Answer the question
In order to leave comments, you need to log in
The simplest, in the file site_name/admin/model/catalog/product.php
At the end you add your own method, for example:
private function getMyKeywords($data){
$keyword_array = array(
'Купить '.$data.' в Москве';
//Тут собственно додумываешь как организовать шаблон
);
return implode(', ', $keyword_array);
}
foreach ($data['product_description'] as $language_id => $value)
I have line 14. $value['meta_keyword'] .= $this->getMyKeywords($value['name']);
Some wild things went...
For a product card:
Meta tags are set in /catalog/controller/product/product.php here prntscr.com/befqtm
In your case prntscr.com/beft8i
If you do not need the first letter in the product name to lowercase, then remove the lcfirst() function.
The ucfirst() function is written in the screenshot, I made a typo, I need lcfirst()
Probably, for such a simple phrase, it is enough to enter it directly into the code.
Find the following controller code. To do this, in the file "catalog/controller/product/product.php" we find the following line:
$this->document->setTitle($product_info['meta_title']);
// Проверям, что мета-теги не пусты + что контент-менеджер не скопипастил название тоавар, что тоже случается :)
if (!$product_info['meta_title'] && $product_info['meta_title'] != $product_info['name']) {
$product_info['meta_title'] = 'Купить ' . $product_info['name'] . ' в Москве';
}
if (!$product_info['meta_description'] && $product_info['meta_description'] != $product_info['name']) {
$product_info['meta_description'] = $product_info['name'] . ' Купить в Москве по выгодным ценам';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question