mytheory. Posted February 28, 2010 Share Posted February 28, 2010 Hello,I've been setting up my shop for the past couple of months using prestashop, and due to an abundant amount of information on these forums (through alot of searching) I haven't had the need to post a question until now. Now that my shop is getting closer to it's relaunch there are a couple of things that I am trying to resolve... which leads to my first question:How would I add a list of manufacturers (within that specific category & subcats) under the category.php page? For example when you click on a main category it shows you the list of products under that category as well as the subcategories (given they exist). How would I list all the manufacturers under that category under the "subcategory" list (in the same format... shows a thumbnail image and the name below it).I have been messing around with the category.tpl under themes.. and was able to get a header (that reads "Manufacturer") and a couple links, but these links seem fairly random including its title. I can't seem to get past this point.I hope this makes sense. And thank you in advance. 1 Link to comment Share on other sites More sharing options...
mytheory. Posted March 2, 2010 Author Share Posted March 2, 2010 Ok... to ask a more specific question with some relation to the topic.What is the code to call out the manufacturer of a product under a subcategory? From what I have looked through $product->id_manufacturer calls the id of the manufacturer for a specific product. However, how would I find all and only the products under a specific category or subcategory, so that from that "product list" I can call the manufacturers? ($product->id_manufacturer works on the product page or any category page with products, but my category pages that have subcategories ususally do not have products under the main category. So my question relates to calling these items from the category page with no products.)To explain a bit further, from the home page I click on say "Category 1" which opens the next page listing the 3 subcategories under "Category 1"... Now I need to compile a "list" of all the products that are only under each of the 3 subcategories (and category as a whole).Thanks. Link to comment Share on other sites More sharing options...
rocky Posted March 3, 2010 Share Posted March 3, 2010 Are you trying to filter categories by manufacturer or just list the manufacturers relevant to the current category? Or to put it another way, when you click on a manufacturer on the category page, do you want only products that are both from that manufacturer and in that category or do you want to list all products by that manufacturer? The former is quite difficult. There are filter modules available, but I'm not aware of any free ones. The latter is easier, since you just have to go through all the $products and get all the unique $product.id_manufacturer values, then create a list similar to the subcategories that link directly to those manufacturer pages. Link to comment Share on other sites More sharing options...
mytheory. Posted March 3, 2010 Author Share Posted March 3, 2010 rocky,First, thanks for you reply.If I understood correctly, I believe I am trying to do something along the lines of the latter (easier method as you put it). I am trying to "list the manufacturers relevant to the current category/subcategory" in the category page.Most of my category pages on my shop are divided into subcategories, which then contain products. So, off the homepage from the category block if I click on a category it takes me to a page that lists only subcategories, and if I click on one of the subcategories it lists the products. What I am trying to do is under the category page that lists only the subcategories, below it I want to list the manufacturers that are unique to only products of the subcategories under that specifc category page.Per my last post, I was able to kind of narrow down what I think I need to do. However, the obstacle I am facing is: if there are products under a page I can get all the unique $product.id_manufacturer values as you said, but the problem is how would I get those values from the category page that ONLY has subcategories? Essentially, how would I tell the code to identify each of the subcategories on that page, then for each subcat get the $product.id_manufacturer w/o duplicates? That way once I can get those values I can output it on the category page under the subcat listings. I am open to any suggestions.Thanks! Link to comment Share on other sites More sharing options...
rocky Posted March 3, 2010 Share Posted March 3, 2010 Add the following to category.php after line 59 ($cat_products = ...): $manufacturers = array(); if ($cat_products) foreach ($cat_products as $product) { $manufacturers[$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), intval($cookie->id_lang)); $manufacturer_images[$product['id_manufacturer']] = (!file_exists(_PS_MANU_IMG_DIR_.'/'.$product['id_manufacturer'].'-medium.jpg')) ? Language::getIsoById(intval($cookie->id_lang)).'-default' : $product['id_manufacturer']; } then add the following to the $smarty->assign on line 71: 'manufacturers' => $manufacturers, 'manufacturer_images' => $manufacturer_images, then add the following to category.tpl in your theme's directory wherever you want the manufacturer list to appear: {if isset($manufacturers)} <!-- Manufacturers --> {l s='Manufacturers'} {foreach from=$manufacturers item=manufacturer} <a href="{$link->getManufacturerLink($manufacturer->id_manufacturer, $manufacturer->link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$manufacturer->name|escape:'htmlall':'UTF-8'}"> {foreach from=$manufacturer_images key=id_manufacturer item=manufacturer_image} {if $id_manufacturer == $manufacturer->id_manufacturer} <img src="{$img_manu_dir}{$manufacturer_image|escape:'htmlall':'UTF-8'}-medium.jpg" alt="" /> {/if} {/foreach} <a href="{$link->getManufacturerLink($manufacturer->id_manufacturer, $manufacturer->link_rewrite)|escape:'htmlall':'UTF-8'}">{$manufacturer->name|escape:'htmlall':'UTF-8'} {/foreach} {/if} Link to comment Share on other sites More sharing options...
mytheory. Posted March 4, 2010 Author Share Posted March 4, 2010 rocky,you are a genius! Thank you for this code, it brings everything one step closer.I have 2 issues:1) Manufacturers are successfully listed in a subcategory (with products), but it only lists the manufacturers on that pagination. When I go to the next page it lists only the manufacturers on that page... Is there any way to display the manufacturers of all the products in the subcategory and not just the pages alone?2) So, when somebody clicks on a category from the homepage it takes them to another page that lists out the subcategories (and if they click on a subcat. they are taken to the products, which aside from issue #1 works). Usually on these pages there are no products, and consequently there are no manufacturers that are listing. I think it has something to do with there being no products on these "category" (subcategory) pages, thus no id_manufacturers are being arrayed. Is there anyway to parse the manufacturers of all the subcategories on this page?Thanks!PS. For the above code, $manufacturers = array(); if ($cat_products) foreach ($cat_products as $product) { $manufacturers[$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), intval($cookie->id_lang)); $manufacturer_images[$product['id_manufacturer']] = (!file_exists(_PS_MANU_IMG_DIR_.'/'.$product['id_manufacturer'].'-medium.jpg')) ? Language::getIsoById(intval($cookie->id_lang)).'-default' : $product['id_manufacturer']; } you need to add:$manufacturer_images = array();under$manufacturers = array();to display thumbnails without error.Cheer! Link to comment Share on other sites More sharing options...
rocky Posted March 4, 2010 Share Posted March 4, 2010 Try the following code instead of the above code in category.php after line 59: $manufacturer_fields = getManufacturers($category->id_category); $manufacturers = $manufacturer_fields['object']; $manufacturer_images = $manufacturer_fields['image']; And add this function on line 77 (before the $smarty->assign): function getManufacturers($id_category) { global $cookie; $manufacturers = array(); $category = new Category($id_category); $products = $category->getProducts(intval($cookie->id_lang), 1, 1000000); if ($products) foreach ($products as $product) { $manufacturers['object'][$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), intval($cookie->id_lang)); $manufacturers['image'][$product['id_manufacturer']] = (!file_exists(_PS_MANU_IMG_DIR_.'/'.$product['id_manufacturer'].'-medium.jpg')) ? Language::getIsoById(intval($cookie->id_lang)).'-default' : $product['id_manufacturer']; } $subcategories = $category->getSubcategories(intval($cookie->id_lang)); if ($subcategories) foreach ($subcategories as $subcategory) $manufacturers = array_merge($manufacturers, getManufacturers($subcategory['id_category'])); return $manufacturers; } This function will recursively get all the unique manufacturers in the current category and its subcategories. I added the parameters "page" = 1 and "number of products per page" = 1000000, since I can't see any option to get all the products in a category. I doubt you'll have more than 1000000 products in a category, so it should work. 1 Link to comment Share on other sites More sharing options...
mytheory. Posted March 4, 2010 Author Share Posted March 4, 2010 rocky,You are the man! The above codes worked perfectly! I can't thank you enough for you help. I made some minor formatting changes on the .tpl file but other than that the function of what I was trying to achieve is right on.Thanks again! Link to comment Share on other sites More sharing options...
mytheory. Posted April 10, 2010 Author Share Posted April 10, 2010 This is a minor problem I just recently noticed, but since I like to pay attention to the details... Is there anyway to sort the manufacturers alphabetically? I think the current code is sorting them according to the manufacturer ID.If there is an easy fix that would be great, if not I can live with it.Thanks again! Link to comment Share on other sites More sharing options...
Nihplod Posted April 13, 2010 Share Posted April 13, 2010 Hi.First, thanks for the code.I'm starting with prestashop and I made some probes with this final code, but doesn´t work well, because only shows the manufacturers of the last subcategory, and doesn´t show the manufacturers of the principal category, nor of the firsts subcategories.I think that, perhaps, mytheory has the same manufacturers inside the differents subcategories and so, the manufacturers shows well.Is possible any change in the code for a correct operation?.Thanks again. Link to comment Share on other sites More sharing options...
mytheory. Posted April 14, 2010 Author Share Posted April 14, 2010 Nihplod,After taking a closer look at my shop and the functioning of the above code... I am having the same (or similar) problem. I didn't notice it earlier because I modified the code to output a small thumbnail of the manufacturer instead of any text, and seeing as how I have not been able to input an image for all the manufacturers yet I presumed that I was just missing the image for a particular manufacturer under a category/subcat.From my experience, I think each of the subcategories are working. However, in the main category (parent) the manufacturers that are being listed is from the same list as the last subcategory under that parent category.I'm going to try and mess around with it, but seeing as how I am not a programmer I think we could use some help.Thanks! Link to comment Share on other sites More sharing options...
Nihplod Posted April 20, 2010 Share Posted April 20, 2010 Hello.I'm newbie, but I made some changes in the code, and now seems to work well, although I am trying to do that clicking over the manufacturer, only shows the items that this manufacturer has in the category, and not all the items that has in store, but I need help. The modified function: function getManufacturers($id_category) { global $cookie; $manufacturers = array(); $catmanufacturers = array(); $allmanufacturers = array(); $category = new Category($id_category); $products = $category->getProducts(intval($cookie->id_lang), 1, 1000000); if ($products) foreach ($products as $product) { $manufacturers['object'][$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), intval($cookie->id_lang)); $manufacturers['image'][$product['id_manufacturer']] = (!file_exists(_PS_MANU_IMG_DIR_.'/'.$product['id_manufacturer'].'-medium.jpg')) ? Language::getIsoById(intval($cookie->id_lang)).'-default' : $product['id_manufacturer']; } $subcategories = $category->getSubcategories(intval($cookie->id_lang)); if ($subcategories) foreach ($subcategories as $subcategory) { $category = new Category($subcategory); $products = $category->getProducts(intval($cookie->id_lang), 1, 1000000); if ($products) foreach ($products as $product) { $catmanufacturers['object'][$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), intval($cookie->id_lang)); $catmanufacturers['image'][$product['id_manufacturer']] = (!file_exists(_PS_MANU_IMG_DIR_.'/'.$product['id_manufacturer'].'-medium.jpg')) ? Language::getIsoById(intval($cookie->id_lang)).'-default' : $product['id_manufacturer']; } } $allmanufacturers = array_merge($manufacturers, $catmanufacturers); return $allmanufacturers; } Link to comment Share on other sites More sharing options...
Nihplod Posted April 22, 2010 Share Posted April 22, 2010 I made some changes in the code, and now seems to work well... I made some test and the code that I had modified doesn't work well, because shows all the manufacturers ever.I'm sorry. Link to comment Share on other sites More sharing options...
noesac Posted June 15, 2010 Share Posted June 15, 2010 I just tried this and it "sort of" worked: http://tiny.cc/bvtyqFor some reason it's only showing one manufacturer, can anyone tell what's wrong with the code?Also is it possible to hide the "Manufacturer" label and logo, and just show the text, e.g. Brand 1 Brand 2 Brand 3 etc... Link to comment Share on other sites More sharing options...
GeoffyB Posted September 11, 2010 Share Posted September 11, 2010 Hi, This works great, however, is there a way of displaying the manufacturers under that category in a list like the manufacturers module?Cheers,Geoff Link to comment Share on other sites More sharing options...
kanodoe Posted November 26, 2010 Share Posted November 26, 2010 I think the problem it was: if ($subCategories) and not if ($subcategories) as appears in the code.A little hard to figure out but it works Regards Link to comment Share on other sites More sharing options...
Crisp Posted November 30, 2010 Share Posted November 30, 2010 Mmm Think im doing something wrong. Its showing every product from the manufacturer instead of just the products from the manufacturer in the specific subcategory. Link to comment Share on other sites More sharing options...
mrbizzy Posted December 1, 2010 Share Posted December 1, 2010 The original version of this hack forks for me as it is described to.But the "improvements" are breaking my site and no products are showed at all.Can someone put together a working hack with instructions please??Casper Link to comment Share on other sites More sharing options...
torres Posted February 14, 2011 Share Posted February 14, 2011 does not work in 1.3.6. anyone know if it works? . Thanks Link to comment Share on other sites More sharing options...
TheCorpse Posted March 20, 2011 Share Posted March 20, 2011 Hi, after reading this topic, and using rocky's hints I have managed to add a dropdown menu just above sort options with the manufacturers only in this category/subcategory. Works on v1.3.7.0So here it is:In classes/Category.php find public function getProducts and modify it as follows: public function getProducts($id_lang, $p, $n, $orderBy = NULL, $orderWay = NULL, $getTotal = false, $active = true, $random = false, $randomNumberProducts = 1,[b] $id_manufacturer = NULL[/b]) { global $cookie; if ($p < 1) $p = 1; if (empty($orderBy)) $orderBy = 'position'; else /* Fix for all modules which are now using lowercase values for 'orderBy' parameter */ $orderBy = strtolower($orderBy); if (empty($orderWay)) $orderWay = 'ASC'; if ($orderBy == 'id_product' OR $orderBy == 'date_add') $orderByPrefix = 'p'; elseif ($orderBy == 'name') $orderByPrefix = 'pl'; elseif ($orderBy == 'manufacturer') { $orderByPrefix = 'm'; $orderBy = 'name'; } elseif ($orderBy == 'position') $orderByPrefix = 'cp'; if ($orderBy == 'price') $orderBy = 'orderprice'; if (!Validate::isBool($active) OR !Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay)) die (Tools::displayError()); $id_supplier = intval(Tools::getValue('id_supplier')); /* Return only the number of products */ if ($getTotal) { $result = Db::getInstance()->getRow(' SELECT COUNT(cp.`id_product`) AS total FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product` WHERE cp.`id_category` = '.intval($this->id).($active ? ' AND p.`active` = 1' : '').' [b] '.($id_manufacturer ? 'AND p.id_manufacturer = '.$id_manufacturer : '').'[/b] '.($id_supplier ? 'AND p.id_supplier = '.intval($id_supplier) : '')); return isset($result) ? $result['total'] : 0; } $sql = ' SELECT p.*, pa.`id_product_attribute`, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`, cl.`name` AS category_default, 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` * IF(t.`rate`,((100 + (t.`rate`))/100),1) - IF((DATEDIFF(`reduction_from`, CURDATE()) <= 0 AND DATEDIFF(`reduction_to`, CURDATE()) >=0) OR `reduction_from` = `reduction_to`, IF(`reduction_price` > 0, `reduction_price`, (p.`price` * IF(t.`rate`,((100 + (t.`rate`))/100),1) * `reduction_percent` / 100)),0)) AS orderprice FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1) LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.intval($id_lang).') LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($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` = '.intval($id_lang).') LEFT JOIN `'._DB_PREFIX_.'tax` t ON t.`id_tax` = p.`id_tax` LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.intval($id_lang).') LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE cp.`id_category` = '.intval($this->id).($active ? ' AND p.`active` = 1' : '').' [b] '.($id_manufacturer ? 'AND p.id_manufacturer = '.$id_manufacturer : '').'[/b] '.($id_supplier ? 'AND p.id_supplier = '.$id_supplier : ''); if ($random === true) { $sql .= ' ORDER BY RAND()'; $sql .= ' LIMIT 0, '.intval($randomNumberProducts); } else { $sql .= ' ORDER BY '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).' LIMIT '.((intval($p) - 1) * intval($n)).','.intval($n); } $result = Db::getInstance()->ExecuteS($sql); if ($orderBy == 'orderprice') { Tools::orderbyPrice($result, $orderWay); } if (!$result) return false; /* Modify SQL result */ return Product::getProductsProperties($id_lang, $result); } Added one more parameter for the function - $id_manufacturer defaults to NULLin the SQL addded the WHERE clause id_manufacturer if id_manufacturer is not NULL Link to comment Share on other sites More sharing options...
TheCorpse Posted March 20, 2011 Share Posted March 20, 2011 NEXT In the root directory of Prestashop file category.phpSomewhere around line 58 find $nbProducts = $category->getProducts(NULL, NULL, ............. and replace with $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true, TRUE, FALSE, 1,[b] intval(Tools::getValue('id_manufacturer'))[/b]); Three rows down find $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p)...... and replace with $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay, FALSE, TRUE, FALSE, 1, intval(Tools::getValue('id_manufacturer'))); just after that add $manufacturers = getManufacturers($category->id_category); So it looks like that: if ($category->id != 1) { $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true, TRUE, FALSE, 1, intval(Tools::getValue('id_manufacturer'))); include(dirname(__FILE__).'/pagination.php'); $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay, FALSE, TRUE, FALSE, 1, intval(Tools::getValue('id_manufacturer'))); $manufacturers = getManufacturers($category->id_category); } After that in the $smarty->asign add 'manufacturers' => $manufacturers, $smarty->assign(array( 'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL, 'manufacturers' => $manufacturers, 'id_category' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name)), 'path' => Tools::getPath(intval($category->id), $category->name), 'homeSize' => Image::getSize('home') )); After the end of the IF clause (two rows after the end of $smarty->asign) add the following function function getManufacturers($id_category) { global $cookie; $manufacturers = array(); $category = new Category($id_category); $products = $category->getProducts(intval($cookie->id_lang), 1, 1000000, NULL, NULL, FALSE, TRUE, FALSE, 1); if ($products) foreach ($products as $product) { $manufacturers[$product['id_manufacturer']] = Manufacturer::getNameById($product['id_manufacturer']); } $subcategories = $category->getSubcategories(intval($cookie->id_lang)); if ($subcategories) foreach ($subcategories as $subcategory) $manufacturers = array_merge($manufacturers, getManufacturers($subcategory['id_category'])); return $manufacturers; } This is rocky's function a little bit modified. So starting from line 56 - if ($category->id != 1) the file looks like that: if ($category->id != 1) { $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true, TRUE, FALSE, 1, intval(Tools::getValue('id_manufacturer'))); include(dirname(__FILE__).'/pagination.php'); $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay, FALSE, TRUE, FALSE, 1, intval(Tools::getValue('id_manufacturer'))); $manufacturers = getManufacturers($category->id_category); } $smarty->assign(array( 'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL, 'manufacturers' => $manufacturers, 'id_category' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name)), 'path' => Tools::getPath(intval($category->id), $category->name), 'homeSize' => Image::getSize('home') )); } } function getManufacturers($id_category) { global $cookie; $manufacturers = array(); $category = new Category($id_category); $products = $category->getProducts(intval($cookie->id_lang), 1, 1000000, NULL, NULL, FALSE, TRUE, FALSE, 1); //print_r($products); if ($products) foreach ($products as $product) { $manufacturers[$product['id_manufacturer']] = Manufacturer::getNameById($product['id_manufacturer']); } $subcategories = $category->getSubcategories(intval($cookie->id_lang)); if ($subcategories) foreach ($subcategories as $subcategory) $manufacturers = array_merge($manufacturers, getManufacturers($subcategory['id_category'])); return $manufacturers; } $smarty->assign(array( 'allow_oosp' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')), 'suppliers' => Supplier::getSuppliers(), 'errors' => $errors)); if (isset($subCategories)) $smarty->assign(array( 'subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2))); $smarty->display(_PS_THEME_DIR_.'category.tpl'); include(dirname(__FILE__).'/footer.php'); ?> Link to comment Share on other sites More sharing options...
TheCorpse Posted March 20, 2011 Share Posted March 20, 2011 And finally the in themes/theme001/product-sort.tpl {if isset($orderby) AND isset($orderway)} <!-- Sort products --> {if $smarty.get.id_category|intval} {assign var='request' value=$link->getPaginationLink('category', $category, false, true)} {elseif $smarty.get.id_manufacturer|intval} {assign var='request' value=$link->getPaginationLink('manufacturer', $manufacturer, false, true)} {elseif $smarty.get.id_supplier|intval} {assign var='request' value=$link->getPaginationLink('supplier', $supplier, false, true)} {else} {assign var='request' value=$link->getPaginationLink(false, false, false, true)} {/if} <form id="productsSortForm" action="{$request}"> {if !strstr($request, 'search.php')} {l s='--'} {foreach from=$manufacturers key=mkey item=manufacturer name=manufacturers} {$manufacturer} {/foreach} {l s='Manufacturer'} {/if} {l s='--'} {l s='price: lowest first'} {l s='price: highest first'} {l s='name: A to Z'} {l s='name: Z to A'} {l s='in-stock first'} {l s='sort by'} </form> <!-- /Sort products --> {/if} if you compare the original file with that on you will find the diff: {if !strstr($request, 'search.php')} {l s='--'} {foreach from=$manufacturers key=mkey item=manufacturer name=manufacturers} {$manufacturer} {/foreach} {l s='Manufacturer'} {/if} I think that this is it. Sorry if I have forgotten something. Hope it will work on your stores. I have only tested it on Prestashop v1.3.7.0. Dunno if it will work on other versions. Link to comment Share on other sites More sharing options...
TheCorpse Posted March 20, 2011 Share Posted March 20, 2011 I just realized I don't need this code in function getManufacturers if ($subcategories) foreach ($subcategories as $subcategory) $manufacturers = array_merge($manufacturers, getManufacturers($subcategory['id_category'])); It is to get manufacturers when you are on category page that has subcategories. But since I don display manufacturers there, I don't need this code. Link to comment Share on other sites More sharing options...
TheCorpse Posted March 20, 2011 Share Posted March 20, 2011 That code works also on Prestashop v1.4.0.17 but you have to do some modifications on the code in category.php since the code is in controllers/CategoryController.php. You have to make the function getManufacturers member of the class CategoryControllerCore. change some of the properties like $category->getProducts into $this->category->getProducts;intval(Tools::getValue('id_manufacturer')) into (int)(Tools::getValue('id_manufacturer')). The function getProducts is modified and has one more parameter, so you should add it when calling the function. When I have some more time, I will post the code for v.1.4.0.17 Link to comment Share on other sites More sharing options...
hnight24 Posted April 27, 2011 Share Posted April 27, 2011 Hican you post the code for prestashop 1.4?Thanks Link to comment Share on other sites More sharing options...
NithyaStephen Posted February 18, 2012 Share Posted February 18, 2012 can you help me to find this solution in version 1.4.7.0 Link to comment Share on other sites More sharing options...
tzatzo Posted March 3, 2012 Share Posted March 3, 2012 Hello, Apologies if this is an off-topic but I need just the opposite. I would like to get the categories sold by a manufacturer. I mean, when I click on a manufacturer, I need to get all categories that this manufacturer sells. Is there any module for this? Regards. Link to comment Share on other sites More sharing options...
drroot Posted March 15, 2012 Share Posted March 15, 2012 Nice. Any idea how to make this code compatible with version 1.4.7? Link to comment Share on other sites More sharing options...
B. Szakacs Posted May 26, 2012 Share Posted May 26, 2012 Up for 1.4.7! Anybody? Link to comment Share on other sites More sharing options...
mleczakm Posted February 1, 2014 Share Posted February 1, 2014 I have working code for presta 1.5, also with filtering by manufacturer, you demo is here - suple.michalmleczko.waw.pl - but i won't distrubute it for free - 10 euro, by paypal, 15 if you want my help with installing etc. Link to comment Share on other sites More sharing options...
Bilegt Posted October 30, 2014 Share Posted October 30, 2014 Try the following code instead of the above code in category.php after line 59: $manufacturer_fields = getManufacturers($category->id_category);$manufacturers = $manufacturer_fields['object'];$manufacturer_images = $manufacturer_fields['image']; And add this function on line 77 (before the $smarty->assign): function getManufacturers($id_category){ global $cookie; $manufacturers = array(); $category = new Category($id_category); $products = $category->getProducts(intval($cookie->id_lang), 1, 1000000); if ($products) foreach ($products as $product) { $manufacturers['object'][$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), intval($cookie->id_lang)); $manufacturers['image'][$product['id_manufacturer']] = (!file_exists(_PS_MANU_IMG_DIR_.'/'.$product['id_manufacturer'].'-medium.jpg')) ? Language::getIsoById(intval($cookie->id_lang)).'-default' : $product['id_manufacturer']; } $subcategories = $category->getSubcategories(intval($cookie->id_lang)); if ($subcategories) foreach ($subcategories as $subcategory) $manufacturers = array_merge($manufacturers, getManufacturers($subcategory['id_category'])); return $manufacturers;} This function will recursively get all the unique manufacturers in the current category and its subcategories. I added the parameters "page" = 1 and "number of products per page" = 1000000, since I can't see any option to get all the products in a category. I doubt you'll have more than 1000000 products in a category, so it should work. any updated version for 1.6 Rocky? Link to comment Share on other sites More sharing options...
presciak Posted December 15, 2014 Share Posted December 15, 2014 where can I find these files? Link to comment Share on other sites More sharing options...
elisa1212 Posted January 30, 2015 Share Posted January 30, 2015 Hi, would like to show manufacturer block in category page and product detail, but only for one category of my site. is it possible? thanks Link to comment Share on other sites More sharing options...
Mantvis_Sireika Posted February 12, 2015 Share Posted February 12, 2015 How i can do this in prestashop 1,6? 1 Link to comment Share on other sites More sharing options...
elisa1212 Posted February 17, 2015 Share Posted February 17, 2015 any help? Link to comment Share on other sites More sharing options...
benzenewings Posted June 8, 2015 Share Posted June 8, 2015 Please, this is NOT Solved now in 1.6... those code overrides will not work any more. Can someone help on getting these manufactures to display on categories in 1.6? 1 Link to comment Share on other sites More sharing options...
pandoras Posted August 4, 2015 Share Posted August 4, 2015 Not found the code in category.php which is now redirected and runnning from index.php Please help Link to comment Share on other sites More sharing options...
mohamd.sobhy Posted May 19, 2016 Share Posted May 19, 2016 any ideas how it work with 1.6 ? 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