Jump to content

[SOLVED]Add navigation between manufacturers


Recommended Posts

Hi all !

I was wondering how to add "Next" and "Prev" buttons in the manufacturer page to navigate between them ?
Is there a simple way or have to override the manufacturer class to achieve this ?

Thanks in advance for you replies !

Regards.

EDIT : To achieve this override ManufacturerController.php file putting it in overrides/controller/front/

and put that code in :

class ManufacturerController extends ManufacturerControllerCore
{
	
	protected function assignOne()
	{
		$data = Manufacturer::getManufacturers(false, $this->context->language->id, true, false, false, false);
		$this->manufacturer->description = Tools::nl2br(trim($this->manufacturer->description));
		$nbProducts = $this->manufacturer->getProducts($this->manufacturer->id, null, null, null, $this->orderBy, $this->orderWay, true);
		$this->pagination((int)$nbProducts);

		$products = $this->manufacturer->getProducts($this->manufacturer->id, $this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay);
		$this->addColorsToProductList($products);
		$prev = false;
		$next = false;
		for ($i=0; $i<count($data); $i++){
			if ($this->manufacturer->id == $data[$i]['id_manufacturer']){
				if ($i > 0) $prev = $data[$i-1];
				if ($i < count($data)-1) $next = $data[$i+1];
			}
		}
		$this->context->smarty->assign(array(
			'prev' => $prev,
			'next' => $next,			
			'nb_products' => $nbProducts,
			'products' => $products,
			'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''),
			'manufacturer' => $this->manufacturer,
			'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'),
			'body_classes' => array($this->php_self.'-'.$this->manufacturer->id, $this->php_self.'-'.$this->manufacturer->link_rewrite)
		));
	}

}

Then in your manufacturer.tpl you can use {$next} and {$prev}.

That's all folks !!

Edited by yomas (see edit history)
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...