diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 001c5c750..961a4d11d 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -83,7 +83,14 @@ class Product extends BaseLoop ) ), Argument::createBooleanTypeArgument('random', 0), - Argument::createIntListTypeArgument('exclude') + Argument::createIntListTypeArgument('exclude'), + Argument::createIntListTypeArgument('exclude_category'), + new Argument( + 'feature_available', + new TypeCollection( + new Type\IntToCombinedIntsList(array('alpha', 'alpha_reverse', 'reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new')) + ) + ) ); } @@ -295,6 +302,15 @@ class Product extends BaseLoop $search->filterById($exclude, Criteria::NOT_IN); } + $exclude_category = $this->getExclude_category(); + + if (!is_null($exclude_category)) { + $search->filterByCategory( + CategoryQuery::create()->filterById($exclude_category, Criteria::IN)->find(), + Criteria::NOT_IN + ); + } + /** * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. * diff --git a/core/lib/Thelia/Type/EnumType.php b/core/lib/Thelia/Type/EnumType.php index ce9914038..0221f8b8e 100755 --- a/core/lib/Thelia/Type/EnumType.php +++ b/core/lib/Thelia/Type/EnumType.php @@ -48,7 +48,7 @@ class EnumType implements TypeInterface return in_array($value, $this->values); } - public function getFogetFormattedValuermatedValue($value) + public function getFormattedValue($value) { return $this->isValid($value) ? $value : null; } diff --git a/core/lib/Thelia/Type/IntToCombinedIntsList.php b/core/lib/Thelia/Type/IntToCombinedIntsList.php new file mode 100755 index 000000000..9c8445b6e --- /dev/null +++ b/core/lib/Thelia/Type/IntToCombinedIntsList.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Type; + +/** + * + * @author Etienne Roudeix + * + */ + +class IntToCombinedIntsList implements TypeInterface +{ + public function getType() + { + return 'Int to combined ints list type'; + } + + public function isValid($values) + { + foreach(explode(',', $values) as $intToCombinedInts) { + $parts = explode(':', $intToCombinedInts); + if(count($parts) != 2) + return false; + if(filter_var($parts[0], FILTER_VALIDATE_INT) === false) + return false; + if(!preg_match('#([0-9]+)|\*|&\*]+#', $parts[1])) + return false; + } + + return true; + } + + public function getFormattedValue($values) + { + return $this->isValid($values) ? explode(',', $values) : null; + } +} diff --git a/templates/smarty-sample/category.html b/templates/smarty-sample/category.html index 1589036a4..dad8764b9 100755 --- a/templates/smarty-sample/category.html +++ b/templates/smarty-sample/category.html @@ -19,7 +19,7 @@
{/loop*}

PRODUCTS

-{loop name="product" type="product" order="promo,min_price"} +{loop name="product" type="product" order="promo,min_price" exclude_category="3"}

PRODUCT : #REF / #TITLE

price : #PRICE €
promo price : #PROMO_PRICE €