Jump to content

[solved] Display Manufacturer name in block cart resume


Recommended Posts

No answers??

 

The closest i get is to display the manufacturer id

 

{$product.id_manufacturer}

 

But i need to display just the name...

 

i've tried several things:

 

{$product.manufacturer_name}

{$product->manufacturer_name}

 

with no result...

 

Please, help!!

Link to comment
Share on other sites

  • 9 months later...

Hi ByScripts,

 

As for why is this post "solved" it must be the main user who changed it.

 

To be sure to help you I'll need some informations : What's your version of Prestashop? You want to display it on the shopping-cart.tpl (Cart Resume)? Do you want only the name?

 

There's a lot of way to achieve this, it all depends on your situation.

 

Martin

Link to comment
Share on other sites

Hi, thank you for your answer.

 

I'm using the last version of Prestashop (1.5.4.1).

 

I just need the manufacturer name.

 

I want it to be displayed in "blockcart.tpl".

 

In the products loop, $product only contains the manufacturer ID, but not the name.

 

I suppose that a SQL query must be changed to retrieve the name.

 

Thanks.

Link to comment
Share on other sites

I want it to be displayed in "blockcart.tpl".

 

Block cart is the block loaded on every pages. That isn't just the summary.

Almost every pages/modules who are displaying cart products uses "cart->getProducts".

 

If you are familiar with Prestashop, I suggest you override this function from classes/cart.php:

 

/**
 * Return cart products
 *
 * @result array Products
 */
public function getProducts($refresh = false, $id_product = false, $id_country = null)

 

Good luck!

 

Martin

Link to comment
Share on other sites

Block cart is the block loaded on every pages. That isn't just the summary.

Almost every pages/modules who are displaying cart products uses "cart->getProducts".

 

If you are familiar with Prestashop, I suggest you override this function from classes/cart.php:

 

/**
 * Return cart products
 *
 * @result array Products
 */
public function getProducts($refresh = false, $id_product = false, $id_country = null)

 

Good luck!

 

Martin

 

Thank you ! It helped a lot !

 

Here is a (the?) solution:

 

- Create the file /override/classes/Cart.php

- Make a Cart class extending CartCore

- Copy the original getProducts

- Near line 28, after

p.`id_manufacturer`

add

, m.`name` AS manufacturer_name

- Then near line 38, after

$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');

add this line :

$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');

 

It's now possible to use $products->manufacturer_name :)

 

Thanks again.

 

 

 

author of this thread marked it as [solved] without solution, im going to unmark it

 

Thank you. I suppose you can now mark it as Solved again :D

Link to comment
Share on other sites

That was the solution I had in mind too. Easier to go and modify the SQL request since it's on every pages.

 

I'm a purist, I wouldn't have added the LEFT JOIN if the requierement for manufacturer name were just on the Summary (1 page).

 

Join affects performance a lot in SQL. Since this function is called everywhere, it would've been a waste of time to join a table unused. I would probally have added all the manufacturers concerned in the accessable vars. (ParentOrderController->_assignSummaryInformations)

 

@vekia Are you ubiquitous?? Or are you just stalking me?

 

Martin

Link to comment
Share on other sites

  • 6 months later...
  • 4 months later...
×
×
  • Create New...