Dear Vekia I see you often help people here and I need your help becuse no one reponded to me in the forum. I need to hide certen category to show in new product block, is this possible? PS I am also you customer i mypresta website. thank you so much
Hide products from defined categories in "new products"
Started by OVOnel, Dec 01 2017 12:24 AM
1 reply to this topic
looking for the best presta addons with outstanding support? check this: PrestaShop Modules
#2
Posted 01 December 2017 - 12:24 AM
Hello
By default it is not possible, it requires modification of prestashop core - Product.php class.
there is a function:
/** * Get new products * * @param int $id_lang Language id * @param int $pageNumber Start from (optional) * @param int $nbProducts Number of products to return (optional) * @return array New products */ public static function getNewProducts($id_lang, $page_number = 0, $nb_products = 10, $count = false, $order_by = null, $order_way = null, Context $context = null) {
inside of this function you can find a code:
if (Group::isFeatureActive()) { $groups = FrontController::getCurrentCustomerGroups(); $sql->where('EXISTS(SELECT 1 FROM `'._DB_PREFIX_.'category_product` cp JOIN `'._DB_PREFIX_.'category_group` cg ON (cp.id_category = cg.id_category AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1').') WHERE cp.`id_product` = p.`id_product`)'); }
right after this code please paste this one line:
$sql->where('p.id_category_default NOT in (2,3,4)');
Where the 2,3,4 is a categories ID numbers that you want to exclude from "new products".
This code will not show products with default category ID: 2,3,4 (just replace ID with own category id you want to hide)
free tutorials, free templates, free addons, prestashop modules