Jump to content

Manufacturer Description in Home Featured Products


stuffedhippo

Recommended Posts

In my homefeatured.tpl I have added:

 

{$product.manufacturer_name|escape:'htmlall':'UTF-8'}

 

which pulls in the manufacturer related to that product. Great I thought all I have to do now is pull in the desciption/short description so thought the following would work:

 

{$product.manufacturer_description|escape:'htmlall':'UTF-8'}

 

However this pulls up an error:

 

Notice: Undefined index: manufacturer_short_description

 

Any help in resolving this would be really appreciated.

 

Thanks

Link to comment
Share on other sites

Unfortunately, it is not so simple. The product only has the manufacturer ID and name available to it, not the manufacturer description. You will need to override classes/Product.php and search for manufacturer_name and add similiar code for the manufacturer description. For example, add the field:

 

/** @var string Manufacturer description */
public  $manufacturer_description;

 

and in the __construct() function, change:

 

$this->manufacturer_name = Manufacturer::getNameById((int)$this->id_manufacturer);

 

to:

 

$manufacturer = new Manufacturer((int)$this->id_manufacturer, (int)$id_lang);
$this->manufacturer_name = $manufacturer->name;
$this->manufacturer_description = $manufacturer->description;

 

and in the getProducts() function, change:

 

$rq = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT p.*, pl.* , t.`rate` AS tax_rate, m.`name` AS manufacturer_name, s.`name` AS supplier_name
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
  AND tr.`id_country` = '.(int)Country::getDefaultCountryId().'
  AND tr.`id_state` = 0)
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
LEFT JOIN `'._DB_PREFIX_.'supplier` s ON (s.`id_supplier` = p.`id_supplier`)'.
($id_category ? 'LEFT JOIN `'._DB_PREFIX_.'category_product` c ON (c.`id_product` = p.`id_product`)' : '').'
WHERE pl.`id_lang` = '.(int)($id_lang).
($id_category ? ' AND c.`id_category` = '.(int)($id_category) : '').
($only_active ? ' AND p.`active` = 1' : '').'
ORDER BY '.(isset($orderByPrefix) ? pSQL($orderByPrefix).'.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).
($limit > 0 ? ' LIMIT '.(int)($start).','.(int)($limit) : '')
);

 

to:

 

$rq = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT p.*, pl.* , t.`rate` AS tax_rate, m.`name` AS manufacturer_name, ml.`description` AS manufacturer_description, s.`name` AS supplier_name
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
  AND tr.`id_country` = '.(int)Country::getDefaultCountryId().'
  AND tr.`id_state` = 0)
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
LEFT JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer`)
LEFT JOIN `'._DB_PREFIX_.'supplier` s ON (s.`id_supplier` = p.`id_supplier`)'.
($id_category ? 'LEFT JOIN `'._DB_PREFIX_.'category_product` c ON (c.`id_product` = p.`id_product`)' : '').'
WHERE pl.`id_lang` = '.(int)($id_lang).'AND ml.`id_lang` = '.(int)($id_lang).
($id_category ? ' AND c.`id_category` = '.(int)($id_category) : '').
($only_active ? ' AND p.`active` = 1' : '').'
ORDER BY '.(isset($orderByPrefix) ? pSQL($orderByPrefix).'.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).
($limit > 0 ? ' LIMIT '.(int)($start).','.(int)($limit) : '')
);

 

You'll need to make a similar change in the getNewProducts(), getPricesDrop() and getAccessories() functions.

Link to comment
Share on other sites

Thanks Rocky for the instructions.

 

Unfortunately when it comes down to in-depth PHP my skills are lacking somewhat. Have now spent 3 hours going through the instructions with no avail.

 

Hopefully somebody else may fins this post useful and get it to work.

 

Thanks for you time to reply.

 

Rich

Link to comment
Share on other sites

In my homefeatured.tpl I have added:

 

{$product.manufacturer_name|escape:'htmlall':'UTF-8'}

 

which pulls in the manufacturer related to that product. Great I thought all I have to do now is pull in the desciption/short description so thought the following would work:

 

{$product.manufacturer_description|escape:'htmlall':'UTF-8'}

 

However this pulls up an error:

 

Notice: Undefined index: manufacturer_short_description

 

Any help in resolving this would be really appreciated.

 

Thanks

 

Can you please tell me how can I add MANUFACTURER NAME for my HomeFeatured Products? I read your post but I didn't understand what to add where and what code to add wherE?

 

Can you please be more specific and elaborate each steps. Thanks

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