Added product parapter

This commit is contained in:
Franck Allimant
2014-06-30 14:49:58 +02:00
parent 6bc22fd7ef
commit 31182c07fc

View File

@@ -21,6 +21,7 @@ use Thelia\Core\Template\Element\SearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\BrandQuery;
use Thelia\Model\ProductQuery;
use Thelia\Type\BooleanOrBothType;
use Thelia\Type;
use Thelia\Type\TypeCollection;
@@ -45,6 +46,7 @@ class Brand extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLoo
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
Argument::createIntTypeArgument('product'),
Argument::createBooleanOrBothTypeArgument('visible', 1),
Argument::createAnyTypeArgument('title'),
new Argument(
@@ -103,6 +105,12 @@ class Brand extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLoo
$search->filterById($id, Criteria::IN);
}
$product = $this->getProduct();
if (!is_null($product) && null !== $productObj = ProductQuery::create()->findPk($product)) {
$search->filterByProduct($productObj);
}
$visible = $this->getVisible();
if ($visible !== BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);