Someone approached me the other day with an interesting question. They wanted to remove their shop name from the meta titles that Prestashop creates. This was a request that I haven’t heard yet and could not find much information on. So I am going to share with you what I did. As a note, I am using Prestashop 1.5.4.1 for this tutorial.
Removing the Meta Titles
You are going to need an ftp client and a text editor to do this. I suggest Filezilla for the FTP client and Sublime Text for the text editor.
FTP into your site and open the classes/Meta.php file, this is where all of the meta tag goodness is stored. The first place you want to look is line 225. This is where the Prestashop puts the shop name on the index page. It should look like the image below.
You are going to need to change the code on line 225 to this
$ret</p>['meta_title'] = (isset($metas['title']) && $metas['title']) ? $metas['title'] : Configuration::get('PS_SHOP_NAME');</pre>Now lets move down to line 282, this is where the pagination starts. We need to take the shop name off of this area too. You files should look like the image below.
We are going to change the code above to look this to take off the shop title during the pagination
// Paginate title if (!empty($row['meta_title'])) $row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : ''); else $row['meta_title'] = $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : ''); if (!empty($title)) $row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : ''); return Meta::completeMetaTags($row, $row['name']); }The next part in the code controls the meta titles on the manufacturers pages. It looks like this.
You will need to change the code to this, to remove the shop name from the meta title of the manufacturers pages.
public static function getManufacturerMetas($id_manufacturer, $id_lang, $page_name) { $page_number = (int)Tools::getValue('p'); $sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords` FROM `'._DB_PREFIX_.'manufacturer_lang` ml LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (ml.`id_manufacturer` = m.`id_manufacturer`) WHERE ml.id_lang = '.(int)$id_lang.' AND ml.id_manufacturer = '.(int)$id_manufacturer; if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) { if (empty($row['meta_description'])) $row['meta_description'] = strip_tags($row['meta_description']); $row['meta_title'] = ($row['meta_title'] ? $row['meta_title'] : $row['name']).(!empty($page_number) ? ' ('.$page_number.')' : ''); return Meta::completeMetaTags($row, $row['meta_title']); } return Meta::getHomeMetas($id_lang, $page_name); }The next part of the code controls the suppliers pages and this is what it looks like.
It will need to be modified to this.
public static function getSupplierMetas($id_supplier, $id_lang, $page_name) { $sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords` FROM `'._DB_PREFIX_.'supplier_lang` sl LEFT JOIN `'._DB_PREFIX_.'supplier` s ON (sl.`id_supplier` = s.`id_supplier`) WHERE sl.id_lang = '.(int)$id_lang.' AND sl.id_supplier = '.(int)$id_supplier; if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) { if (empty($row['meta_description'])) $row['meta_description'] = strip_tags($row['meta_description']); if (!empty($row['meta_title'])) $row['meta_title'] = $row['meta_title']; return Meta::completeMetaTags($row, $row['name']); } return Meta::getHomeMetas($id_lang, $page_name); }We are almost done, only a couple more places left. The next one is for the CMS pages, it looks like this.
It needs to be edited to be this.
public static function getCmsMetas($id_cms, $id_lang, $page_name) { $sql = 'SELECT `meta_title`, `meta_description`, `meta_keywords` FROM `'._DB_PREFIX_.'cms_lang` WHERE id_lang = '.(int)$id_lang.' AND id_cms = '.(int)$id_cms; if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) { $row['meta_title'] = $row['meta_title']; return Meta::completeMetaTags($row, $row['meta_title']); } return Meta::getHomeMetas($id_lang, $page_name); }Now for the last two places, since they are right beside each other I am going to handle them together. This area controls the category pages and the product pages. It will look like this.
Replace the code above with this code and you will be finished.
public static function getCmsCategoryMetas($id_cms_category, $id_lang, $page_name) { $sql = 'SELECT `meta_title`, `meta_description`, `meta_keywords` FROM `'._DB_PREFIX_.'cms_category_lang` WHERE id_lang = '.(int)$id_lang.' AND id_cms_category = '.(int)$id_cms_category; if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) { $row['meta_title'] = $row['meta_title']; return Meta::completeMetaTags($row, $row['meta_title']); } return Meta::getHomeMetas($id_lang, $page_name); } /** * @since 1.5.0 */ public static function completeMetaTags($meta_tags, $default_value, Context $context = null) { if (!$context) $context = Context::getContext(); if (empty($meta_tags['meta_title'])) $meta_tags['meta_title'] = $default_value; if (empty($meta_tags['meta_description'])) $meta_tags['meta_description'] = Configuration::get('PS_META_DESCRIPTION', $context->language->id) ? Configuration::get('PS_META_DESCRIPTION', $context->language->id) : ''; if (empty($meta_tags['meta_keywords'])) $meta_tags['meta_keywords'] = Configuration::get('PS_META_KEYWORDS', $context->language->id) ? Configuration::get('PS_META_KEYWORDS', $context->language->id) : ''; return $meta_tags; } }Now that you have everything edited, upload it and check your site out. You should have more space now to put in keyword rich descriptions for your product, categories, cms pages, suppliers, and manufacturers now. If this is something you feel you cannot handle by yourself, contact us and we can do it for you.
About the Author: Lesley Paone
Lesley has worked in e-commerce for over a decade, and is the founder of dh42. Starting out with PrestaShop and brancing out into other platforms like Shopify. He loves all things e-commerce and loves a challenge, in his spare time he helps moderate several forums on SEO, e-commerce, as well as the PrestaShop forum. If you have any questions for him about any of his articles just use our contact form to contact him.