product loop feature
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
57
core/lib/Thelia/Type/IntToCombinedIntsList.php
Executable file
57
core/lib/Thelia/Type/IntToCombinedIntsList.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
<hr />
|
||||
{/loop*}
|
||||
<h2>PRODUCTS</h2>
|
||||
{loop name="product" type="product" order="promo,min_price"}
|
||||
{loop name="product" type="product" order="promo,min_price" exclude_category="3"}
|
||||
<h3>PRODUCT : #REF / #TITLE</h3>
|
||||
price : #PRICE €<br />
|
||||
promo price : #PROMO_PRICE €<br />
|
||||
|
||||
Reference in New Issue
Block a user