Jump to content

[Solved] List Manufacturers Under Category Page. Ps1.5+


Marianosc
 Share

Recommended Posts

Hi,

 

I am trying to do exactly what was achieved in the thread below, except it was done pre-PS1.5 many moons ago:

 

http://www.prestasho...-category-page/

 

Basically I want to add a list of manufactures within that specific category and its subcategories so that it can be filtered on. This is when looking at the product-list view.

 

I follow and understand what was achieved in the tread but am struggling to adapt it to PS1.5+ structure.

 

Any assistance is greatly appreciated.

 

Cheers,

 

Mariano.

Edited by Marianosc (see edit history)

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Well I figured it out.

 

Needed to to create a Category Contoller Override

 

Then in the "class CategoryController extends CategoryControllerCore"

 

Copy the original "assignProductListModify" from CategoryController.php and at the end of the funtion "public function assignProductList()" you need to modify it to the following:

 

$this->manufacturers = array();

if ($this->cat_products)
 foreach ($this->cat_products as &$product) {
	   $this->manufacturers[$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), $this->context->language->id);
 }
 $this->context->smarty->assign(array(
	   'nb_products', $this->nbProducts,
	   'manufacturers' => $this->manufacturers,
 ));

 

Hope that helps anyone else looking to do the same.

 

Cheers,

 

Mariano.

Share this post


Link to post
Share on other sites

  • 4 weeks later...

Well I figured it out.

 

Needed to to create a Category Contoller Override

 

Then in the "class CategoryController extends CategoryControllerCore"

 

Copy the original "assignProductListModify" from CategoryController.php and at the end of the funtion "public function assignProductList()" you need to modify it to the following:

 

$this->manufacturers = array();

if ($this->cat_products)
 foreach ($this->cat_products as &$product) {
	   $this->manufacturers[$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), $this->context->language->id);
 }
 $this->context->smarty->assign(array(
	   'nb_products', $this->nbProducts,
	   'manufacturers' => $this->manufacturers,
 ));

 

Hope that helps anyone else looking to do the same.

 

Cheers,

 

Mariano.

 

Got this working so far (I have data in the manufacturer array), but how do I add the dropdown to filter by these manufacturers in the product-list?

Share this post


Link to post
Share on other sites

Nookyx,

 

In my case I was populating the product-list.tpl with a list of checkboxes of manufactures instead of a dropdown list. Below is my code which you should be able to modify to a dropdown list instead:

 

	  {if $manufacturers|@count >1}
		  <li> <strong>Manufactures</strong>
		  <ul id="filter_manufactures">
			    {if isset($manufacturers)}

			  <!-- Manufacturers -->
				  {foreach from=$manufacturers item=manufacturer}
						  <li>
							  <input type='checkbox' class='filterCheckbox filterCheckboxManufactures' id='Filter-{$manufacturer->name|escape:'htmlall':'UTF-8'}' name='Filter-{$manufacturer->name|escape:'htmlall':'UTF-8'}' value='{$manufacturer->name|escape:'htmlall':'UTF-8'}' />
							  {$manufacturer->name|escape:'htmlall':'UTF-8'}
						  </li>   
				  {/foreach}
			  {/if}
		    </ul>
		  </li>
	    {/if}

 

Cheers,

 

Mariano

Share this post


Link to post
Share on other sites

thanks so far, I've been able to list them in a dropdown. But how does the actual filtering occur? I guess I need to override some functions, but which ones, where and how? I'm stuck here atm :(

Share this post


Link to post
Share on other sites

  • 4 months later...
  • 4 months later...
  • 1 year later...

I saw you had a breakthrough getting the manufacturers listed on categories for 1.5. I am trying to use your code on 1.6 and perhaps missing a step. I added the override on categorycontroller and added the call in productslist.tpl. . .is there anywhere else I need to edit? Best I get on the front page is.. Undefined index: manufacturers in tools/smarty/sysplugins/smarty_internal_templatebase.php(171) : eval()'d code on line 53  

Maybe I have the override added wrong? Any help is greatly appreciated.

Share this post


Link to post
Share on other sites

  • 3 years later...
  • 8 months later...

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More