Jump to content

Display Manufacturer meta title on product page and Manufacturer list?


icaclassics

Recommended Posts

Hi

 

I’m trying to find a way to display the manufacturer meta title on product pages (product.tpl) and the manufacturer list (manufacturer.list.tpl). I have tried both {$manufacturer.meta_title} and {$manufacturer->meta_title} and neither work, nothing displays. I’m using Prestashop version 1.5.4.1.

 

The reason I need it is because I’m using manufacturers as music artists, so each one has a first name and last name. Many of our products also have simply the artist name as the product title, so both in order to not duplicate urls and for the benefit of having the manufacturer list in alphabetical order by surname (which we want) I have given each manufacturer the title in the format of ‘lastname, firstname’. I then do ‘firstname lastname’ in the meta title. This means on the individual manufacturer pages I get the page title as ‘firstname lastname’ (both in the meta and on the page, because {$manufacturer->meta_title} works on manufacturer.tpl, but not anywhere else.)

 

Is there a way of writing a function that would call the manufacturer meta title to print on product and manufacturer list? Or any other solution? Any help gratefully received!!

 

Thank you!

Link to comment
Share on other sites

  • 1 year later...

Hi, I solve the issue of this way:

 

add 'meta_keywords' field on classes/Manufacturer.php, getManufacturers function:

 

Before:

 

public static function getManufacturers($get_nb_products = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_group = false, $group_by = false)
{
if (!$id_lang)
$id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
if (!Group::isFeatureActive())
$all_group = true;


$manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT m.*, ml.`description`, ml.`short_description`
FROM `'._DB_PREFIX_.'manufacturer` m
'.Shop::addSqlAssociation('manufacturer', 'm').'
INNER JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer` AND ml.`id_lang` = '.(int)$id_lang.')
'.($active ? 'WHERE m.`active` = 1' : '')
.($group_by ? ' GROUP BY m.`id_manufacturer`' : '' ).'
ORDER BY m.`name` ASC
'.($p ? ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n : ''));
if ($manufacturers === false)
return false;

After:

public static function getManufacturers($get_nb_products = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_group = false, $group_by = false)
{
if (!$id_lang)
$id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
if (!Group::isFeatureActive())
$all_group = true;


$manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT m.*, ml.`description`, ml.`short_description`, ml.`meta_keywords` 
FROM `'._DB_PREFIX_.'manufacturer` m
'.Shop::addSqlAssociation('manufacturer', 'm').'
INNER JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer` AND ml.`id_lang` = '.(int)$id_lang.')
'.($active ? 'WHERE m.`active` = 1' : '')
.($group_by ? ' GROUP BY m.`id_manufacturer`' : '' ).'
ORDER BY m.`name` ASC
'.($p ? ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n : ''));
if ($manufacturers === false)
return false;

and call this one in tpl file: {$manufacturer.meta_keywords}

Edited by sete (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...