neo81na Posted September 19, 2012 Share Posted September 19, 2012 hi.. i would like to add send two parametrs to the page category.. like id_category and id_manufacturer for filter products of the category that have the manufacturer in id_manucfaturer how i can do it?.. please help me.. Link to comment Share on other sites More sharing options...
math_php Posted September 19, 2012 Share Posted September 19, 2012 Hi, You will have make an override of category controller and modify category.tpl Link to comment Share on other sites More sharing options...
neo81na Posted September 19, 2012 Author Share Posted September 19, 2012 Hi, You will have make an override of category controller and modify category.tpl can you make me an example please? Link to comment Share on other sites More sharing options...
math_php Posted September 19, 2012 Share Posted September 19, 2012 What version of prestashop do you use ? Have you a website where I can see your manufacturer list ? Do you have a jpg of what you want, to display filter ? You want button in category page to switch from manufacturer a to b ? Link to comment Share on other sites More sharing options...
neo81na Posted September 19, 2012 Author Share Posted September 19, 2012 thanks really much.. http://www.computeridea.org/palmart/ i edited the manufacturer for show image in change of text.. i want on click in manufacturer show category list.. with saved that manufacturer this way when i click on category i can show the products inside only of that manufacturer.. showing upside the manufactuer name and a button for clear the manufacturer filter. the prestashop version is 1.4.8.2 thanks for your help.. i'm new to php.. even if costruct are similar to vb.net or vb.. i'm having many difficult. Link to comment Share on other sites More sharing options...
math_php Posted September 19, 2012 Share Posted September 19, 2012 Ok step by step, to be clear and because I am not sure to understand : - home page click on one manufacturer -> go to category page with filter on this manufacturer : show an all products list of this manufacturer ? Click on Ferrari will show all cars from - racing category - and turismo category If this is right category controller will not be used. Else - home page click on one manufacturer -> go to category page with filter on this manufacturer : show all categories where this manufacturer is ? What is the good way ? Link to comment Share on other sites More sharing options...
neo81na Posted September 19, 2012 Author Share Posted September 19, 2012 - home page click on one manufacturer -> go to category page with filter on this manufacturer : show all categories where this manufacturer is click on category.. show all products and subcategory where this manufacturer is. Link to comment Share on other sites More sharing options...
math_php Posted September 19, 2012 Share Posted September 19, 2012 Okay now I know how to do : - adapt blockmanufacturer - make an override of category controller or to create specific one I will come back to you. 1 Link to comment Share on other sites More sharing options...
benjamin utterback Posted September 19, 2012 Share Posted September 19, 2012 Hello all, I want to thank math_php for this awesome display of community in helping out a fellow PrestaShop merchant. This is what we are all about! Link to comment Share on other sites More sharing options...
neo81na Posted September 19, 2012 Author Share Posted September 19, 2012 Hello all, I want to thank math_php for this awesome display of community in helping out a fellow PrestaShop merchant. This is what we are all about! yes many thanks.. you are really kind. Link to comment Share on other sites More sharing options...
math_php Posted September 19, 2012 Share Posted September 19, 2012 (edited) Well I am not used to such kindness. Anyway In manufacturer.tpl you have to change the link manufacturer.php to something like this <a href="category.php?id_manufacturer={$manufacturer.id_manufacturer}" Then create a php file named : CategoryController.php and put it into override/controllers Then in this file put this <?php class CategoryController extends CategoryControllerCore{ public function process() { parent::process(); $id_manufacturer = Tools::getValue('id_manufacturer',NULL); if ($id_manufacturer === NULL) { return;} $this->errors[] = Tools::displayError('ID manufacturer ='.$id_manufacturer); $rq="SELECT distinct cp.id_category,cl.name from "._DB_PREFIX_."product p INNER JOIN "._DB_PREFIX_."category_product cp ON p.id_product = cp.id_product INNER JOIN "._DB_PREFIX_."category_lang cl ON cp.id_category = cl.id_category WHERE p.id_manufacturer=".(int)$id_manufacturer ." AND cl.id_lang=".(int)(self::$cookie->id_lang); $result = Db::getInstance()->ExecuteS($rq); var_dump($result); } } I hope this will be a good start to finish the job (else let see tomorrow) Good dev Edited : wrong use of smiley Edited September 24, 2012 by math_php (see edit history) Link to comment Share on other sites More sharing options...
neo81na Posted September 19, 2012 Author Share Posted September 19, 2012 thanks for your help.. but i lost myself somewhere in the code... i tryed your example.. but i don't know where to put the file category controller because i already have one of it. in classes folder anyway thanks to your example i could pass and read the parameter manufacturer betwen manufactuer_list to category and take it with me when i click on sub category i wet on category.php in classes folder and i tryed to change the query getproducts for filter by manufacturer .. declared public id_product and get again the value this way public $id_manufacturer; .. ... .. function getproducts (..... .. . $id_manufacturer= (int)(Tools::getValue('id_manufacturer')); { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->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 (p.`id_manufacturer` =' .(int)($id_manufacturer). ' or ' .(int)($id_manufacturer). '= 0) AND cp.`id_category` = '.(int)($this->id).($active ? ' AND p.`active` = 1' : '').' '.($id_supplier ? 'AND p.id_supplier = '.(int)($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)) 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` = '.(int)($id_lang).') 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_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE (p.`id_manufacturer` =' .(int)($id_manufacturer). ' or ' .(int)($id_manufacturer). '= 0) AND cp.`id_category` = '.(int)($this->id).($active ? ' AND p.`active` = 1' : '').' but it give me error where am i wrong?. Link to comment Share on other sites More sharing options...
neo81na Posted September 19, 2012 Author Share Posted September 19, 2012 ok.. somehow now it work.. i don't know where i mistake before.. anyway now it works... but i would like to to show even categories filtered what do you think if i change the getcategories function? anyway thanks for everythigs.. Link to comment Share on other sites More sharing options...
math_php Posted September 20, 2012 Share Posted September 20, 2012 Hi neo81na Do not modify CategoryController in controllers/CategoryController do like this Then create a php file named : CategoryController.php and put it into override/controllers You will benefit from 'prestashop' categoryController behaviour and you will be able to complete it with the behaviour you want. Find here under usefull documentation you need to know about prestashop Link to comment Share on other sites More sharing options...
neo81na Posted September 20, 2012 Author Share Posted September 20, 2012 (edited) ok in this case... where i have to create the file categorycontrollers.. and how i put it in override/controllers?? can you give me some advise .. i mean i know what means extend and override a class.. but i don't know how to do it in prestashop.. have i to write an include somewhere?. thanks Edited September 20, 2012 by neo81na (see edit history) Link to comment Share on other sites More sharing options...
math_php Posted September 20, 2012 Share Posted September 20, 2012 On your ftp access in the prestashop directory, you do not have an 'override' folder as you have an 'modules' folder ? Link to comment Share on other sites More sharing options...
neo81na Posted September 27, 2012 Author Share Posted September 27, 2012 hi.. i end the develop... you can see what i did thanks to your help on this site.. http://www.palmart.it many thanks Link to comment Share on other sites More sharing options...
math_php Posted September 28, 2012 Share Posted September 28, 2012 It looks like it is working well. A 'solved' for this topic would be really nice as well. Regards 1 Link to comment Share on other sites More sharing options...
benjamin utterback Posted September 28, 2012 Share Posted September 28, 2012 Hello, thank you for solution! I will go ahead and mark this thread as SOLVED. Thank you for choosing PrestaShop! Link to comment Share on other sites More sharing options...
alepul Posted October 20, 2012 Share Posted October 20, 2012 Hello guys! I have been following your discussion, and I will try to make changes to the version being restyling 1.4.9. In the meantime, I need to make the same change to version 1.3.6 Any advice .... I just can not figure out which file to edit? Tanks! 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