iAreku Posted May 26, 2014 Share Posted May 26, 2014 (edited) HI!Im new to Prestashop and as I understand this slider, it just posts a link to all and every manufacturer on your store, is that so? I guess I must change this in blockmanufacturers.php public function hookLeftColumn($params) { if (!$this->isCached('blockmanufacturer.tpl', $this->getCacheId())) { $manufacturers = Manufacturer::getManufacturers(); foreach ($manufacturers as &$manufacturer) { $manufacturer['image'] = $this->context->language->iso_code.'-default'; if (file_exists(_PS_MANU_IMG_DIR_.$manufacturer['id_manufacturer'].'-'.ImageType::getFormatedName('medium').'.jpg')) $manufacturer['image'] = $manufacturer['id_manufacturer']; } $this->smarty->assign(array( 'manufacturers' => $manufacturers, 'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'), 'text_list_nb' => Configuration::get('MANUFACTURER_DISPLAY_TEXT_NB'), 'form_list' => Configuration::get('MANUFACTURER_DISPLAY_FORM'), 'display_link_manufacturer' => Configuration::get('PS_DISPLAY_SUPPLIERS'), )); } return $this->display(__FILE__, 'blockmanufacturer.tpl', $this->getCacheId()); } but where's the query made? how can I limit it to, let's say, just the last 15 manufacturers that had "new products" added to them? Right now, how is the manufacturer "list" sorted or picked? at random? by id? Thanks! Edited May 26, 2014 by iAreku (see edit history) Link to comment Share on other sites More sharing options...
iAreku Posted May 26, 2014 Author Share Posted May 26, 2014 Updated. Link to comment Share on other sites More sharing options...
vekia Posted May 26, 2014 Share Posted May 26, 2014 you have to change this function: $manufacturers = Manufacturer::getManufacturers(); (manufacturers class from classes directory) you need to add there order by clause in sql query. Link to comment Share on other sites More sharing options...
iAreku Posted May 26, 2014 Author Share Posted May 26, 2014 I guess if i dont want to play with core files, i'll have to manually "move" the query inside the module right? Link to comment Share on other sites More sharing options...
iAreku Posted May 26, 2014 Author Share Posted May 26, 2014 Any1 kind enough to explain me (translate me) what is this query doing? $manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT m.*, ml.`description`, ml.`short_description` FROM `'._DB_PREFIX_.'manufacturer` m '.Shop::addSqlAssociation('manufacturer', 'm').' INNER JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer` AND ml.`id_lang` = '.(int)$id_lang.') '.($active ? 'WHERE m.`active` = 1' : '').' ORDER BY m.`name` ASC '.($p ? ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n : '')); "extracts all manufacturers in the language required where...." active=1? what does that mean? limit by what? Thanks! Link to comment Share on other sites More sharing options...
iAreku Posted June 1, 2014 Author Share Posted June 1, 2014 Any1 else? Link to comment Share on other sites More sharing options...
vekia Posted June 1, 2014 Share Posted June 1, 2014 active = 1 means that manufacturer must be active 1 - active 0 - turned off Link to comment Share on other sites More sharing options...
iAreku Posted June 1, 2014 Author Share Posted June 1, 2014 And the limit part? How many manufacturers does the query "extract"? All of them that are active? Up to how many? Link to comment Share on other sites More sharing options...
vekia Posted June 1, 2014 Share Posted June 1, 2014 limit is defined here: '.($p ? ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n : '')); it's "shorthand if" contiotion in simple words: if $p is defined that limit will be equal to $n variable (there is also pagination variable $p, but in this case it's not important) to limit number of manufacturers from your module you mentioned, in module php file change: $manufacturers = Manufacturer::getManufacturers(); to $manufacturers = Manufacturer::getManufacturers(false,null,true,0,20); this query will extract 20 manufacturers, you can change 20 to any other number you want Link to comment Share on other sites More sharing options...
iAreku Posted June 1, 2014 Author Share Posted June 1, 2014 Thanks vekia!Can this be made so only the manufacturers that had "recent additions" (products) show up? Thanks! Link to comment Share on other sites More sharing options...
vekia Posted June 1, 2014 Share Posted June 1, 2014 with basic query - no, its not possible. cases like that needs customization, in this case customization of manufacturers controller (query you mentioned) Link to comment Share on other sites More sharing options...
iAreku Posted June 3, 2014 Author Share Posted June 3, 2014 So can any1 help on which query(s) would be required and where to add them?Ty!! Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 4, 2014 Share Posted June 4, 2014 Hi. One solution would be to get the list of the new products,fetch their manufacturer ID and fetch their data. In this case the number of manufacturers displayed can vary from 0 to the total NR of new products. If you want to display a constant number of manufacturers (e.g.:15) you can retrieve the first 15 products having distinct manufacturer ID and ordered by date_add DESC. To fetch the new products you can have a look at the 'getNewProducts' method of the Product class. No core changes are required. (Except to the module file) Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
iAreku Posted June 4, 2014 Author Share Posted June 4, 2014 One solution would be to get the list of the new products,fetch their manufacturer ID and fetch their data. In this case the number of manufacturers displayed can vary from 0 to the total NR of new products. This sounds like what i need can u help out? cheers 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