Jump to content

[SOLVED] Add Specials to Price Drop Page


Recommended Posts

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

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

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 by iantooke (see edit history)
  • Like 2
Link to comment
Share on other sites

  • 2 months later...
  • 4 months later...

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

×
×
  • Create New...