How to display supplier_name into product-list.tpl - Development - PrestaShop

Jump to content

Photo

How to display supplier_name into product-list.tpl

product-list name supplier display

#1

Posted 09 February 2012 - 07:59 PM

n44ps

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active 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.prestasho...n-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.

#2

Posted 10 February 2012 - 09:04 AM

CartExpert.net

    PrestaShop Fanatic

  • Moderators
  • 1474 Active Posts
Hello,

Are you using PrestaShop 1.4.6.2? Do you have layered navigation enabled?

#3

Posted 12 February 2012 - 12:59 PM

n44ps

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active Posts
Indeed, I'm using 1.4.6.2. And the layered navigation wasn't enabled. I put it on, but still it doesn't work.
What's the point using this module ?

#4

Posted 13 February 2012 - 10:26 AM

CartExpert.net

    PrestaShop Fanatic

  • Moderators
  • 1474 Active Posts
Hello,

No, the layered filter should not be turned on.

You need to check whether there are any modules hooked to 'productListAssign' as they might use a different SQL query and you modify the class files in vain, as those SQL queries will never be executed.

#5

Posted 13 February 2012 - 02:25 PM

n44ps

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active Posts
The block layered wasn't turned on. I have lots of module installed but only 3 are hooked and none to 'productListAssign'. Should I unhooked all my module in order to check if there's something wrong ?

#6

Posted 13 February 2012 - 03:29 PM

CartExpert.net

    PrestaShop Fanatic

  • Moderators
  • 1474 Active Posts
No, you should not unhook all the modules. Are you sure there is no module hooked to it? It will not be displayed in the Back office.

#7

Posted 13 February 2012 - 08:06 PM

n44ps

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active Posts
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 ?

#8

Posted 13 February 2012 - 09:34 PM

Danustyle

    PrestaShop Newbie

  • Members
  • Pip
  • 13 Active Posts
Hi, I have found the same problem, do not operate the variable {$product.supplier_name} in product-list.tpl in other works without problem tpl.

anyone knows how to show it? product.manufacturer_name like it works.


Thanks in advance.

#9

Posted 13 February 2012 - 09:47 PM

CartExpert.net

    PrestaShop Fanatic

  • Moderators
  • 1474 Active Posts
Hello,

Add an echo(1); to the 'then' branch, and a echo(2); to the 'else' branch and refresh product list page. If number 1 appears it means it uses standard functionality, if number 2, then module hooking.

You can remove the echo's after that.

#10

Posted 14 February 2012 - 10:35 AM

n44ps

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active Posts
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.

#11

Posted 14 February 2012 - 10:49 AM

pelingier

    PrestaShop Newbie

  • Members
  • Pip
  • 13 Active Posts
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>

#12

Posted 14 February 2012 - 10:57 AM

n44ps

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active Posts
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.

#13

Posted 14 February 2012 - 11:17 AM

CartExpert.net

    PrestaShop Fanatic

  • Moderators
  • 1474 Active Posts
Are you trying to display now Supplier name or Reference?????

#14

Posted 14 February 2012 - 11:26 AM

n44ps

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active Posts
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.

#15

Posted 06 April 2012 - 06:15 PM

n44ps

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active Posts
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

#16

Posted 09 April 2012 - 01:17 PM

sainttboz

    PrestaShop Newbie

  • Members
  • Pip
  • 18 Active Posts
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.

#17

Posted 20 May 2012 - 12:42 AM

Zaid

    PrestaShop Apprentice

  • Members
  • PipPip
  • 254 Active Posts
this code should work to display supplier name at product-list.tpl (or product.tpl)
{Supplier::getNameById($product->id_supplier)}

Solusi pengiriman di Indonesia support semua kurir.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cookies help us deliver our services. By using our services, you agree to use our cookies.     Learn more