Jump to content

Prices-drop e pagine aggiuntive


cyber

Recommended Posts

Risolto !!!!!!

Aprire il file classes/Product.php

E sostituire il codice alla riga 1072 con questo

static public function getPricesDrop($id_lang, $pageNumber = 0, $nbProducts = 10, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = false, $ending = false)
   {
       global $link, $cookie;
       if (!Validate::isBool($count))
           die(Tools::displayError());

       if ($pageNumber < 0) $pageNumber = 0;
       if ($nbProducts < 1) $nbProducts = 10;
       if (empty($orderBy) || $orderBy == 'position') $orderBy = 'myprice';
       if (empty($orderWay)) $orderWay = 'DESC';
       if ($orderBy == 'id_product' OR $orderBy == 'price' OR $orderBy == 'date_add')
           $orderByPrefix = 'p';
       elseif ($orderBy == 'name')
           $orderByPrefix = 'pl';
       if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay))
           die (Tools::displayError());

       if ($count)
       {
           $sql = '
           SELECT COUNT(DISTINCT p.`id_product`) AS nb
           FROM `'._DB_PREFIX_.'product` p
           WHERE p.`active` = 1
           AND (`reduction_price` > '.intval(0).' OR `reduction_percent` > '.intval(0).')
           AND p.`id_product` IN (
               SELECT cp.`id_product`
               FROM `'._DB_PREFIX_.'category_group` cg
               LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
               WHERE cg.`id_group` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
           )';
           $result = Db::getInstance()->getRow($sql);
           return intval($result['nb']);
       }
       $currentDate = date('Y-m-d');
       $sql = '
       SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, i.`id_image`, il.`legend`, t.`rate`, (p.`reduction_price` + (p.`reduction_percent` * p.`price`)) AS myprice, m.`name` AS manufacturer_name
       FROM `'._DB_PREFIX_.'product` p
       LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($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` = '.intval($id_lang).')
       LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = p.`id_tax`)
       LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
       WHERE (`reduction_price` > '.intval(0).' OR `reduction_percent` > '.intval(0).')
       '.((!$beginning AND !$ending) ?
           'AND (`reduction_from` = `reduction_to` OR (`reduction_from` <= \''.pSQL($currentDate).'\' AND `reduction_to` >= \''.pSQL($currentDate).'\'))'
       :
           ($beginning ? 'AND `reduction_from` <= \''.pSQL($beginning).'\'' : '').($ending ? 'AND `reduction_to` >= \''.pSQL($ending).'\'' : '')).'
       AND p.`active` = 1
       AND p.`id_product` IN (
           SELECT cp.`id_product`
           FROM `'._DB_PREFIX_.'category_group` cg
           LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
           WHERE cg.`id_group` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
       )
       ORDER BY '.(isset($orderByPrefix) ? pSQL($orderByPrefix).'.' : '').'`'.pSQL($orderBy).'`'.' '.pSQL($orderWay).'
       LIMIT '.intval($pageNumber * $nbProducts).', '.intval($nbProducts);
       $result = Db::getInstance()->ExecuteS($sql);
       if($orderBy == 'price')
       {
           Tools::orderbyPrice($result,$orderWay);
       }
       if (!$result)
           return false;
       return Product::getProductsProperties($id_lang, $result);
   }



spero di aver fatto cosa gradita :)

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