Jump to content

Adding Manufacturer Name to Product Page Title


Recommended Posts

Team,

 

I am looking for code that will allow me to add the manufacturer name to the Product Page Title. Can I get some assistance?

 

Meta.php (completeMetaTags function)

 

if (empty($meta_tags['meta_title'])) {
            $meta_tags['meta_title'] = $default_value.' - '.Configuration::get('PS_SHOP_NAME');
        }
 
Would need to add the manufacturer name to meta title, ie: "Manufacturer Name - Skirt - Shop Name"
Link to comment
Share on other sites

Denver, having to pay a developer for a change that someone has already implemented is not what I am looking for. My goal is to make the change myself, which gives me the opportunity to learn how the code works and helps me pass this information on to someone with the same question. I understand where you are coming from in regards to compensation since I am a Java Developer. If no one can answer the question, maybe a call to a developer specialized in this field would be needed in my case. 

Link to comment
Share on other sites

Create override/classes/Meta.php with the following code:
<?php

class Meta extends MetaCore
{
    public static function getProductMetas($id_product, $id_lang, $page_name)
    {
        $sql = 'SELECT pl.`name`, pl.`meta_title`, pl.`meta_description`, pl.`meta_keywords`, pl.`description_short`, m.`name` as manufacturer_name
				FROM `'._DB_PREFIX_.'product` p
				LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`'.Shop::addSqlRestrictionOnLang('pl').')
				'.Shop::addSqlAssociation('product', 'p').'
                LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
				WHERE pl.id_lang = '.(int)$id_lang.'
					AND pl.id_product = '.(int)$id_product.'
					AND product_shop.active = 1';
        if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) {
            if (empty($row['meta_description'])) {
                $row['meta_description'] = strip_tags($row['description_short']);
            }
            return Meta::completeMetaTags($row, ($row['manufacturer_name'] ? $row['manufacturer_name'].' ' : '').$row['name']);
        }

        return Meta::getHomeMetas($id_lang, $page_name);
    }   
}

Remember to go to the Advanced Parameters > Performance tab and click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

  • Like 1
Link to comment
Share on other sites

Thanks rocky,

 

I made the change in the override class and I am not seeing any changes happen, but when I make the change in the classes/Meta.php it works. For testing, I copied the entire Meta.php code into the override/classes folder and it still does not work. Then I saw your last comment about deleting the cache/class_index.php.

 

Another comment: (https://www.prestashop.com/forums/topic/238197-solved-overrides-not-working-anymore-in-154/)

 

After deleting the file it works now!

 

Thank you rocky for your help and I hope this question helps someone in the future!

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...