Jump to content


Photo

Hide products from defined categories in "new products"


  • Please log in to reply
1 reply to this topic

#1 OVOnel

OVOnel

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 01 December 2017 - 12:24 AM

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 



looking for the best presta addons with outstanding support? check this: PrestaShop Modules

#2 vekia

vekia

    Advanced Member

  • Members
  • PipPipPip
  • 10166 posts

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 MndfRK4.png  lpHMrZ5.png  gtKHYO7.png  google-48.png


#3 fnaf12

fnaf12

    Newbie

  • Members
  • Pip
  • 0 posts

Posted 15 November 2022 - 04:38 AM

Do you like to play games? With the challenge brought fall guys is a fun race that you may play with your friends or family after a long day at work. Everyone will enjoy this game because of its charming graphics and enjoyable gameplay.