loop product
This commit is contained in:
@@ -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 . ')';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user