Jump to content

Change New Products Module To Show Prods. From Only One Category


saracoratello

Recommended Posts

Hi there,

 

I want change prestashop new products module hook function to show products from only one category.

Does anyone have idea how can i do this ?

 

I know how to do this by tpl and {$newproduct.category} var, but i find this method as "volatile".

 

Here are default hook function from blocknewproducts.php :

 

public function hookHome($params)
{
 global $smarty;

 $newProducts = Product::getNewProducts((int)($params['cookie']->id_lang), 0, (int)(Configuration::get('NEW_PRODUCTS_NBR')));
 if (!$newProducts AND !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY'))
  return;
 $smarty->assign(array('new_products' => $newProducts, 'mediumSize' => Image::getSize('medium')));

 return $this->display(__FILE__, 'blocknewproducts.tpl');
}

 

Thanks!

Link to comment
Share on other sites

the class Product is what is performing the query to retrieve the new products, inside Product is a function called getNewProducts, so you have 2 options.

 

1) You can override the Product class, and revise the getNewProducts to only return products from a specific category.

2) You can modify the blocknewproducts.php hookHome function so that after you retrieve the products and store them in $newProducts array, you could iterate through that array and remove the products that are not in the target category.

Link to comment
Share on other sites

if you would like me to do it for you, I can, but I do charge for my services. if you would like, send me a PM with the category id you want to filter out and I will make the changes using option 2.

 

just go to this URL, select the "Prestashop Module Installation" option. once paid i will perform the update.

http://www.bellini-services.com/shop/software-solutions/19-prestashop-upgrade.html

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