Jump to content

Brands slider on homepage - How to "limit" it?


iAreku

Recommended Posts

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 by iAreku (see edit history)
Link to comment
Share on other sites

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...