Jump to content

How to display supplier_name into product-list.tpl


n44ps

Recommended Posts

Hello everyone, I've been searching information for a while now and I found some answers.

Actually, I made all what said this topic (http://www.prestashop.com/forums/topic/77057-solved-how-to-include-supplier-name-in-product-list/) and I really thought it would work but in vain.

 

I can even erase the fonction named getProducts (from Category.php), it still displays the same way. But supplier_name isn't displayed...

 

How is that possible ? I put force_compile to "true" and also reboot MAMP...

 

Thanks for helping me.

Link to comment
Share on other sites

I don't know how to check if there are modules hooked to it, I can find the function though :

 

 

public function productListAssign()

{

$hookExecuted = false;

Module::hookExec('productListAssign', array('nbProducts' => &$this->nbProducts, 'catProducts' => &$this->cat_products, 'hookExecuted' => &$hookExecuted));

if(!$hookExecuted) // The hook was not executed, standard working

{

self::$smarty->assign('categoryNameComplement', '');

$this->nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);

$this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"

$this->cat_products = $this->category->getProducts((int)(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);

}

else // Hook executed, use the override

$this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"

self::$smarty->assign('nb_products', (int)$this->nbProducts);

}

 

Does it help ?

Link to comment
Share on other sites

I've just done what you told me to, but no results. Then I've deleted "productListAssign()" : the products are still displayed. Seems like all these functions are not used. CategoryController.php, Category.php doesn't change anything to the process displaying the products in our case.

Link to comment
Share on other sites

Hey I don't know if it helps but to show my product reference I used this code

 

 

<p class="product_desc"><a>Art nr: {$product.reference}</a></p>

<p class="product_desc"><a title="{$product.description_short|truncate:360:'...'|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}">{$product.description_short|truncate:360:'...'|strip_tags:'UTF-8'}</a></p>

Link to comment
Share on other sites

Actually you're right, it works. But it is because it is fetched from Classes/Category.php -> getProducts(), when you have (line 550) "SELECT p.*, pa.`id_product_attribute`, pl.`description`..." You can see that all the information from ps_product are fetched, therefore so is the reference.

Link to comment
Share on other sites

Still supplier_name. In fact I made my own fields in ps_product_lang, like 'vintage' (It's about wine). I can display them in product.tpl {$product->vintage}, I said I wanted to display supplier_name but there are other fields in the same case.

Link to comment
Share on other sites

  • 1 month later...

Hello everyone, It's been a while since I posted my issue. Actually I found what the problem was, so here is the answer.

 

When you want to display your own fields (that you added in the Product Class), it depends on the page you are :

 

Assuming the customer wants the products sorted by suppliers, he's on the page ..yoursite.com/supplier.php?id_supplier=XX

So you should modify the Supplier class, the function remain the same for all the class : getProducts(...)

 

You have something like this :

 

///////////////////////////////////////////////////////////////////////////////////////////////

$sql = '

SELECT p.*, pl.`yourownfield`, pl.`yourownfield2`,pl.`yourownfield3`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend`, s.`name` AS supplier_name, tl.`name` AS tax_name, t.`rate`, DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new,

(p.`price` * ((100 + (t.`rate`))/100)) AS orderprice, m.`name` AS manufacturer_name

FROM `'._DB_PREFIX_.'product` p

LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)($id_lang).')

LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)

LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($id_lang).')

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_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)($id_lang).')

LEFT JOIN `'._DB_PREFIX_.'supplier` s ON s.`id_supplier` = p.`id_supplier`

LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`

WHERE p.`id_supplier` = '.(int)($id_supplier).($active ? ' AND p.`active` = 1' : '').'

AND p.`id_product` IN (

SELECT cp.`id_product`

FROM `'._DB_PREFIX_.'category_group` cg

LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)'.

($active_category ? ' INNER JOIN `'._DB_PREFIX_.'category` ca ON cp.`id_category` = ca.`id_category` AND ca.`active` = 1' : '').'

WHERE cg.`id_group` '.$sqlGroups.'

)

ORDER BY '.(($orderBy == 'id_product') ? 'p.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).'

LIMIT '.(((int)($p) - 1) * (int)($n)).','.(int)($n);

///////////////////////////////////////////////////////////////////////////////////////////////

 

 

Add your fields like above.

 

So each time you want to display your own fields in a page, add your code into the getProducts(...) function of this page.

I hope everything is clear.

 

Best regards,

 

N44PS

Link to comment
Share on other sites

Hello everyone,

i have a slightly different question though:How do i display Supplier logo of each product on the Product Comparison page (i.e the result of the comparison will display supplier logo of each product)

I truly have no idea how to do it...but i know it is possible...any help please.

Link to comment
Share on other sites

  • 1 month later...

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