Jump to content

promotions (bas de page)


Recommended Posts

y'a t'il un moyen de le faire pointer uniquement vers les produits dont la case en solde est cochée?


Oui c'est possible, mais faut toucher au php (après avoir sauvegardé)

Exemple sur la version 1.1.0.5, fichier ./Classes/Product.PHP

Dans la fonction *getPricesDrop* , chercher:
       if ($count)
       {
           $result = Db::getInstance()->getRow('
           SELECT COUNT(`id_product`) AS nb
           FROM `'._DB_PREFIX_.'product`
           WHERE `reduction_price` > 0
           OR `reduction_percent` > 0
           AND `active` = 1');
           return intval($result['nb']);
       }
       $currentDate = date('Y-m-d');
       $result = Db::getInstance()->ExecuteS('
       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` > 0 OR `reduction_percent` > 0)
       '.((!$beginning AND !$ending) ?
           'AND (`reduction_from` = `reduction_to` OR (`reduction_from` <= \''.$currentDate.'\' AND `reduction_to` >= \''.$currentDate.'\'))'
       :
           ($beginning ? 'AND `reduction_from` <= \''.$beginning.'\'' : '').($ending ? 'AND `reduction_to` >= \''.$ending.'\'' : '')).'
       AND p.`active` = 1




*Remplacer par*

       if ($count)
       {
           $result = Db::getInstance()->getRow('
           SELECT COUNT(`id_product`) AS nb
           FROM `'._DB_PREFIX_.'product`
           WHERE `on_sale` > 0
           AND `active` = 1');
           return intval($result['nb']);
       }
       $currentDate = date('Y-m-d');
       $result = Db::getInstance()->ExecuteS('
       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 (`on_sale` > 0)
       AND p.`active` = 1



*Attention...* maintenant les produits qui comportent une remise seront ignorés dans la liste générée par le lien "Promotions".
On ne verra que les produits avec la case "Solde" cochée, qu'il existe ou non une réelle diminution de prix (...)

Link to comment
Share on other sites

En fait pour faire propre il faudrait créer une nouvelle fonction "GetOnSale_Product"
et créer un fichier "on-sale.php" à la racine de PS et "on-sale.tpl" dans le thème.

Ainsi on pourrait proposer deux liens : promo et solde...

Link to comment
Share on other sites

je viens de tester mais cela ne marche pas avec la version 1.2 dommage...


Hello,

Oui c'est surement à cause de la gestion des groupes, la fonction est différente.
Sauvegarde ta fonction dans en lieu sûr dans un fichier texte et remplace-la par celle-ci sur la version 1.2.0.8
(je ne peux pas tester d'où je suis... mais ça devrait aller)
   /**
   * Get prices drop
   *
   * @param integer $id_lang Language id
   * @param integer $pageNumber Start from (optional)
   * @param integer $nbProducts Number of products to return (optional)
   * @param boolean $count Only in order to get total number (optional)
   * @return array Prices drop
   */
   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)
       {
           $result = Db::getInstance()->getRow('
           SELECT COUNT(`id_product`) AS nb
           FROM `'._DB_PREFIX_.'product`
           WHERE `on_sale` = 1
           AND `active` = 1');
           return intval($result['nb']);
       }
       $currentDate = date('Y-m-d');
       $result = Db::getInstance()->ExecuteS('
       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`)
       LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
       INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
       INNER JOIN `'._DB_PREFIX_.'customer_group` cg ON (cg.`id_group` = ctg.`id_group`)
       WHERE (`on_sale` = 1)
       AND p.`active` = 1
       AND (cg.`id_customer` = '.intval($cookie->id_customer).' OR ctg.`id_group` = 1)
       GROUP BY p.`id_product`
       ORDER BY '.(isset($orderByPrefix) ? pSQL($orderByPrefix).'.' : '').'`'.pSQL($orderBy).'`'.' '.pSQL($orderWay).'
       LIMIT '.intval($pageNumber * $nbProducts).', '.intval($nbProducts));
       if($orderBy == 'price')
       {
           Tools::orderbyPrice($result,$orderWay);
       }
       if (!$result)
           return false;
       return Product::getProductsProperties($id_lang, $result);
   }



Le forum fait peut-être des misères au code, j'ai mis un fichier joint avec la fonction seule.

getPricesDrop_function_in_Classes-Product-PHP_version1208.zip

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