loop product

This commit is contained in:
Etienne Roudeix
2013-07-02 16:33:43 +02:00
parent 23aaa4951b
commit 40c0da5553
8 changed files with 164 additions and 60 deletions

View File

@@ -18,4 +18,8 @@ use Thelia\Model\om\BaseProductPeer;
*/
class ProductPeer extends BaseProductPeer
{
public static function getPriceDependingOnPromoExpression()
{
return 'IF(' . self::PROMO . '=1, ' . self::PRICE2 . ', ' . self::PRICE . ')';
}
}

View File

@@ -18,4 +18,15 @@ use Thelia\Model\om\BaseProductQuery;
*/
class ProductQuery extends BaseProductQuery
{
public function filterByPriceDependingOnPromo($minPrice = null, $maxPrice = null)
{
if ($minPrice !== null) {
$this->where(ProductPeer::getPriceDependingOnPromoExpression() . ' ' . \Criteria::GREATER_EQUAL . ' ?', $minPrice);
}
if ($maxPrice !== null) {
$this->where(ProductPeer::getPriceDependingOnPromoExpression() . ' ' . \Criteria::LESS_EQUAL . ' ?', $maxPrice);
}
return $this;
}
}