Jump to content

How to change title in prestashop product page


Recommended Posts

You can change the title of the homepage and some other pages by going to Preferences > Meta-Tags, clicking the Edit button next to a page, then change the "Page's title" field. You can change the title of the CMS pages by going to Tools > CMS, clicking the Edit button next to a page, then changing the "Meta title" field. You can change the title of the products by going to to the product editor and clicking "Click here to improve product's rank in search engines (SEO)", then changing the "Meta title". To change the format of the title from "Shop Name - Title" to "Title | Shop Name", for example, like goosedesign said above, change line 471 of classes/Tools.php from:

$row['meta_title'] = Configuration::get('PS_SHOP_NAME').' - '.$row['meta_title']; 



to:

$row['meta_title'] = $row['meta_title'].' | '.Configuration::get('PS_SHOP_NAME'); 



and line 493 from:

$ret['meta_title'] = (isset($metas['title']) AND $metas['title']) ? Configuration::get('PS_SHOP_NAME').' - '.$metas['title'] : Configuration::get('PS_SHOP_NAME');



to:

$ret['meta_title'] = (isset($metas['title']) AND $metas['title']) ? $metas['title'].' | '.Configuration::get('PS_SHOP_NAME') : Configuration::get('PS_SHOP_NAME');



and line 505 from:

$metaTags['meta_title'] = Configuration::get('PS_SHOP_NAME').' - '.$defaultValue;



to:

$metaTags['meta_title'] = $defaultValue.' | '.Configuration::get('PS_SHOP_NAME');

Link to comment
Share on other sites

You can change the title of the homepage and some other pages by going to Preferences > Meta-Tags, clicking the Edit button next to a page, then change the "Page's title" field. You can change the title of the CMS pages by going to Tools > CMS, clicking the Edit button next to a page, then changing the "Meta title" field. You can change the title of the products by going to to the product editor and clicking "Click here to improve product's rank in search engines (SEO)", then changing the "Meta title". To change the format of the title from "Shop Name - Title" to "Title | Shop Name", for example, like goosedesign said above, change line 471 of classes/Tools.php from:

$row['meta_title'] = Configuration::get('PS_SHOP_NAME').' - '.$row['meta_title']; 



to:

$row['meta_title'] = $row['meta_title'].' | '.Configuration::get('PS_SHOP_NAME'); 



and line 493 from:

$ret['meta_title'] = (isset($metas['title']) AND $metas['title']) ? Configuration::get('PS_SHOP_NAME').' - '.$metas['title'] : Configuration::get('PS_SHOP_NAME');



to:

$ret['meta_title'] = (isset($metas['title']) AND $metas['title']) ? $metas['title'].' | '.Configuration::get('PS_SHOP_NAME') : Configuration::get('PS_SHOP_NAME');



and line 505 from:

$metaTags['meta_title'] = Configuration::get('PS_SHOP_NAME').' - '.$defaultValue;



to:

$metaTags['meta_title'] = $defaultValue.' | '.Configuration::get('PS_SHOP_NAME');



Many thanks! Very helpful!
Link to comment
Share on other sites

  • 2 weeks later...

sorry i do it
but
PHP Warning: Cannot modify header information - headers already sent by (output started at /classes/Tools.php:1) in /header.php on line 4
PHP Warning: Cannot modify header information - headers already sent by (output started at /classes/Tools.php:1) in /classes/Cookie.php on line 261
PHP Warning: Cannot modify header information - headers already sent by (output started at /classes/Tools.php:1) in /classes/Cookie.php on line 261
PHP Warning: Cannot modify header information - headers already sent by (output started at /classes/Tools.php:1) in /order.php on line 12
PHP Warning: Cannot modify header information - headers already sent by (output started at /classes/Tools.php:1) in /order.php on line 13
PHP Warning: Cannot modify header information - headers already sent by (output started at /classes/Tools.php:1) in /classes/Tools.php on line 42

Link to comment
Share on other sites

I cannot see how the changes I suggested would cause that error, since they are only moving existing variables around on the same line. Try changing those lines back to what they were originally and check whether the error disappears or is still there.

Link to comment
Share on other sites

  • 3 months later...

Hi,

I am using 1.2.5.0 as well, and after making the changes I am having the same problem as well in the error logs:

PHP Warning: Cannot modify header information - headers already sent by (output started at public_html/classes/Tools.php:1) in public_html/header.php on line 4

and when I click on my account, it loads a black page with view source "1" only, and nothing else :( and I am unable to update any products etc as well.

In fact, I tried modifying the codes in 1.2.5.0 and it doesnt work, so I just try to change something minimum, like changing the .' | '. to .' - '. only, and I am getting the exact same error, is it because something like after I change the few lines of codes (even by a bit only), the other codes couldnt detect this and hence it is not working? anyone managed to solved the issue in 1.2.5.0 on changeing the Store name - Title, to , Title - Store name?

Hope someone can please share how to make it work.... thank you very much!

Link to comment
Share on other sites

guys anyone happens to use 1.2.5.0 and make the changes to the title tag by changing the arrangment or removing the store name? prestashop doesnt seems to allow me to change anything in the tools.php, strange :(

Link to comment
Share on other sites

  • 2 months later...

Hello, I am using 1.2.5 also and have a question about these title tags.

When on a category page, the shop name is displayed, then the title is displayed...but when on a product page, there is no shop name showing, only the product name.

How can I add the shop name to display also on the product pages.

Thanks,

Link to comment
Share on other sites

You'll need to modify the completeMetaTags function in classes/Tools.php. I think this should do the trick. Change lines 556-557 from:

if ($metaTags['meta_title'] == NULL)
   $metaTags['meta_title'] = $defaultValue.' - '.Configuration::get('PS_SHOP_NAME');



to:

if ($metaTags['meta_title'] == NULL)
   $metaTags['meta_title'] = $defaultValue.' - '.Configuration::get('PS_SHOP_NAME');
else
   $metaTags['meta_title'] .= ' - '.Configuration::get('PS_SHOP_NAME');

Link to comment
Share on other sites

Rocky, thanks for the info on this. In that file I do not have the code you mentioned, instead I have similar code on line 500 of that file:

        static public function getHomeMetaTags($id_lang)
   {
       global $cookie, $page_name;

       /* Metas-tags */
       $metas = Meta::getMetaByPage($page_name, $id_lang);
       $ret['meta_title'] = (isset($metas['title']) AND $metas['title']) ? Configuration::get('PS_SHOP_NAME').' - '.$metas['title'] : Configuration::get('PS_SHOP_NAME');
       $ret['meta_description'] = (isset($metas['description']) AND $metas['description']) ? $metas['description'] : '';
       $ret['meta_keywords'] = (isset($metas['keywords']) AND $metas['keywords']) ? $metas['keywords'] :  '';
       return $ret;
   }


   static public function completeMetaTags($metaTags, $defaultValue)
   {
       global $cookie;

       if ($metaTags['meta_title'] == NULL)
           $metaTags['meta_title'] = Configuration::get('PS_SHOP_NAME').' - '.$defaultValue;
       if ($metaTags['meta_description'] == NULL)
           $metaTags['meta_description'] = Configuration::get('PS_META_DESCRIPTION', intval($cookie->id_lang)) ? Configuration::get('PS_META_DESCRIPTION', intval($cookie->id_lang)) : '';
       if ($metaTags['meta_keywords'] == NULL)
           $metaTags['meta_keywords'] = Configuration::get('PS_META_KEYWORDS', intval($cookie->id_lang)) ? Configuration::get('PS_META_KEYWORDS', intval($cookie->id_lang)) : '';
       return $metaTags;
   }

Link to comment
Share on other sites

  • 7 months later...

The only way I can think of to do that is to add the following before the $smarty->display at the bottom of header.php:

if (isset($_GET['id_product']))
{
   $product = new Product(intval($_GET['id_product']), true, intval($cookie->id_lang));

   if (Validate::isLoadedObject($product))
       $smarty->assign('manufacturer_name', $product->manufacturer_name);
}



then change line 4 of header.tpl in your theme's directory from:

<title>{$meta_title|escape:'htmlall':'UTF-8'}</title>



to:

<title>}if isset($manufacturer_name)}{$manufacturer_name} {/if}{$meta_title|escape:'htmlall':'UTF-8'}</title>

Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...
  • 4 months later...

Hi guys,

 

I want change title format. Rocky wrote here perfect solution (edit lines in classes/Tools.php), but I can not find these lines in PS 1.5.2. Where are they in new version?

 

I want this: "Title | Shop Name"

 

Thanks

Link to comment
Share on other sites

  • 2 years later...
  • 2 months later...
  • 2 years later...

Hi

 

i wanted to change of my title Display Mode Structure :

 

Now My Display Mode Structure is : 

 

Name of Categories Website name

 

but now i wanted just show 

 

Name of Categories

 

and dont show Website name

How to change the title order into my web site ?

 

my prestashop vertion is 1.6.1.7

 

my web site address : https://irandec.com

Edited by Virous.2016 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...