Jump to content

optimisation fonction getNewProducts


Recommended Posts

!!!!!!!!!!!!!!!!!!!!!!!!!!!! pour hacker averti et grosse base de donnée:

je travaille sur 1.6.1.6

 

 

              
        $sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
        
    /*HACK BOF */
        $w = '(product_shop.`active` = 1)';
        if ($front) {
            $w .=(' and (product_shop.`visibility` IN ("both", "catalog"))');
        }
        $w .= (' and product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'"');                
        if (Group::isFeatureActive()) {
            $groups = FrontController::getCurrentCustomerGroups();
            $w .=(' and (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`))');
        }
        $w = 'p.`id_product` in ( 
                                SELECT * from (
                                    SELECT p.id_product FROM `ps_product` p INNER JOIN ps_product_shop product_shop
                                                             ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1)
                                                             where '.$w.'
                                                    ORDER by ' . (isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way) . '
                                                             limit ' . $page_number * $nb_products.', '.(($page_number * $nb_products)+$nb_products) .'    
                                
                                ) as t)';
        
        $sql->where($w);
        
        /*
        $sql->where('product_shop.`active` = 1');
        if ($front) {
            $sql->where('product_shop.`visibility` IN ("both", "catalog")');
        }
        $sql->where('product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'"');
        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`)');
        }        
        
        $sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way));
        $sql->limit($nb_products, $page_number * $nb_products);        
        */
        
    /*HACK EOF */     

        if (Combination::isFeatureActive()) {

 

Edited by emelaz (see edit history)
  • Like 1
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...