iantooke Posted November 5, 2013 Share Posted November 5, 2013 Hi, Currently running 1.5.5.0 Does anyone know how to add items marked as special to the price drop page?? (I know it will work by setting a specific price but i don't want to do that!) Many Thanks Ian Link to comment Share on other sites More sharing options...
vekia Posted November 5, 2013 Share Posted November 5, 2013 you need to modify Product class, especially function: public static function getPricesDrop($id_lang, $page_number = 0, $nb_products = 10, $count = false, $order_by = null, $order_way = null, $beginning = false, $ending = false, Context $context = null) inside of this function you've got sql query. Change it to fetch products marked as "on_sale" (where on_sale field =1 in database) Link to comment Share on other sites More sharing options...
iantooke Posted November 5, 2013 Author Share Posted November 5, 2013 Hi, I don't have that code in "controllers/front/ProductController.php" I do have PricesDropController.php, Would i have to edit this? php below class PricesDropControllerCore extends FrontController { public $php_self = 'prices-drop'; public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'product_list.css'); if (Configuration::get('PS_COMPARATOR_MAX_ITEM')) $this->addJS(_THEME_JS_DIR_.'products-comparison.js'); } /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->productSort(); $nbProducts = Product::getPricesDrop($this->context->language->id, null, null, true); $this->pagination($nbProducts); $this->context->smarty->assign(array( 'products' => Product::getPricesDrop($this->context->language->id, (int)$this->p - 1, (int)$this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM') )); $this->setTemplate(_PS_THEME_DIR_.'prices-drop.tpl'); } } Many Thanks Link to comment Share on other sites More sharing options...
vekia Posted November 5, 2013 Share Posted November 5, 2013 check file: classes/Product.php Link to comment Share on other sites More sharing options...
iantooke Posted November 5, 2013 Author Share Posted November 5, 2013 (edited) For anyone wishing to add items marked as special onto the price drop page on 1.5.5.0 go to: classes/Product.php Change 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` '.$sql_groups.' ) GROUP BY product_shop.id_product ORDER BY '.(isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').pSQL($order_by).' '.pSQL($order_way).' LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products; To 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` '.$sql_groups.' ) OR p.`on_sale` = 1 GROUP BY product_shop.id_product ORDER BY '.(isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').pSQL($order_by).' '.pSQL($order_way).' LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products; Edited November 5, 2013 by iantooke (see edit history) 2 Link to comment Share on other sites More sharing options...
vekia Posted November 5, 2013 Share Posted November 5, 2013 nice one thank you for this query modification thread marked as [solved] with regards, Milos Link to comment Share on other sites More sharing options...
shimondvir Posted January 5, 2014 Share Posted January 5, 2014 Does the same works for Prestashop 1.5.6 ? (and on ?) Link to comment Share on other sites More sharing options...
vekia Posted January 6, 2014 Share Posted January 6, 2014 Does the same works for Prestashop 1.5.6 ? (and on ?) hello, yes, it should work in 1.5.6.x Link to comment Share on other sites More sharing options...
luber_panda Posted January 6, 2014 Share Posted January 6, 2014 Looks like good for trying Link to comment Share on other sites More sharing options...
mehnihma Posted May 10, 2014 Share Posted May 10, 2014 Hi This works But only problem is that it only shows one page with on sale products not all pages And when I change this: if ($count) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT COUNT(DISTINCT p.`id_product`) FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' WHERE product_shop.`active` = 1 AND product_shop.`show_price` = 1 '.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').' '.((!$beginning && !$ending) ? 'AND p.`id_product` IN('.((is_array($tab_id_product) && count($tab_id_product)) ? implode(', ', $tab_id_product) : 0).')' : '').' '.$sql_groups); } to this: if ($count) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT COUNT(DISTINCT p.`id_product`) FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' WHERE product_shop.`active` = 1 AND product_shop.`show_price` = 1 OR p.`on_sale` = 1 '.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').' '.((!$beginning && !$ending) ? 'AND p.`id_product` IN('.((is_array($tab_id_product) && count($tab_id_product)) ? implode(', ', $tab_id_product) : 0).')' : '').' '.$sql_groups); } Sometimes I get products that are not on sale? Link to comment Share on other sites More sharing options...
Recommended Posts