n44ps Posted February 9, 2012 Share Posted February 9, 2012 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 More sharing options...
CartExpert.net Posted February 10, 2012 Share Posted February 10, 2012 Hello, Are you using PrestaShop 1.4.6.2? Do you have layered navigation enabled? Link to comment Share on other sites More sharing options...
n44ps Posted February 12, 2012 Author Share Posted February 12, 2012 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 ? Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 13, 2012 Share Posted February 13, 2012 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. Link to comment Share on other sites More sharing options...
n44ps Posted February 13, 2012 Author Share Posted February 13, 2012 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 ? Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 13, 2012 Share Posted February 13, 2012 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. Link to comment Share on other sites More sharing options...
n44ps Posted February 13, 2012 Author Share Posted February 13, 2012 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 More sharing options...
Danustyle Posted February 13, 2012 Share Posted February 13, 2012 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. Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 13, 2012 Share Posted February 13, 2012 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. Link to comment Share on other sites More sharing options...
n44ps Posted February 14, 2012 Author Share Posted February 14, 2012 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 More sharing options...
pelingier Posted February 14, 2012 Share Posted February 14, 2012 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 More sharing options...
n44ps Posted February 14, 2012 Author Share Posted February 14, 2012 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 More sharing options...
CartExpert.net Posted February 14, 2012 Share Posted February 14, 2012 Are you trying to display now Supplier name or Reference????? Link to comment Share on other sites More sharing options...
n44ps Posted February 14, 2012 Author Share Posted February 14, 2012 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 More sharing options...
n44ps Posted April 6, 2012 Author Share Posted April 6, 2012 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 More sharing options...
sainttboz Posted April 9, 2012 Share Posted April 9, 2012 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 More sharing options...
Zaid Posted May 19, 2012 Share Posted May 19, 2012 this code should work to display supplier name at product-list.tpl (or product.tpl) {Supplier::getNameById($product->id_supplier)} 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now