Jump to content

[SOLVED] Manufacturers Additional parameters


neo81na

Recommended Posts

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

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

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 :wub:

Edited by math_php (see edit history)
Link to comment
Share on other sites

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

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 :)B)

 

28a1ds8.jpg

Link to comment
Share on other sites

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

  • 4 weeks later...

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

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...