|
|
@@ -12,32 +12,33 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface; |
|
|
|
|
|
|
|
class ProductRepositoryQuery extends AbstractRepositoryQuery |
|
|
|
{ |
|
|
|
protected bool $isJoinProductFamily =false; |
|
|
|
protected bool $isJoinSections =false; |
|
|
|
protected bool $isJoinProductFamilySectionProperties =false; |
|
|
|
protected bool $isJoinProductFamily = false; |
|
|
|
protected bool $isJoinSections = false; |
|
|
|
protected bool $isJoinProductFamilySectionProperties = false; |
|
|
|
|
|
|
|
public function __construct(ProductRepository $repository, PaginatorInterface $paginator) |
|
|
|
{ |
|
|
|
parent::__construct($repository, 'product', $paginator); |
|
|
|
} |
|
|
|
|
|
|
|
public function orderByDefault(): \Lc\SovBundle\Repository\AbstractRepositoryQuery |
|
|
|
{ |
|
|
|
return $this->orderBy('position', 'ASC'); |
|
|
|
} |
|
|
|
|
|
|
|
public function joinProductFamily():self |
|
|
|
public function joinProductFamily(): self |
|
|
|
{ |
|
|
|
if (!$this->isJoinProductFamily) { |
|
|
|
$this->isJoinProductFamily = true; |
|
|
|
|
|
|
|
return $this |
|
|
|
->innerJoin('.productFamily', 'productFamily') |
|
|
|
->addSelect('productFamily'); |
|
|
|
->innerJoin('.productFamily', 'productFamily') |
|
|
|
->addSelect('productFamily'); |
|
|
|
} |
|
|
|
return $this; |
|
|
|
} |
|
|
|
|
|
|
|
public function filterBySection(SectionInterface $section):self |
|
|
|
public function filterBySection(SectionInterface $section): self |
|
|
|
{ |
|
|
|
$this->joinProductFamilySectionProperties(false); |
|
|
|
$this->andWhereSection('productFamilySectionProperties', $section); |
|
|
@@ -86,7 +87,7 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function filterIsOnline():self |
|
|
|
public function filterIsOnline(): self |
|
|
|
{ |
|
|
|
$this->joinProductFamily(); |
|
|
|
$this->andWhereStatus('productFamily', 1); |
|
|
@@ -94,8 +95,15 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery |
|
|
|
return $this; |
|
|
|
} |
|
|
|
|
|
|
|
public function filterIsOnSale(): self |
|
|
|
{ |
|
|
|
$this->joinProductFamily(); |
|
|
|
$this->andWhere('productFamily.saleStatus = 1'); |
|
|
|
return $this; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function filterIsOriginProduct():self |
|
|
|
public function filterIsOriginProduct(): self |
|
|
|
{ |
|
|
|
$this->andWhere('.originProduct = 1'); |
|
|
|
return $this; |
|
|
@@ -108,61 +116,61 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function filterIsNotAvailableQuantitySupplierUnlimited():self |
|
|
|
public function filterIsNotAvailableQuantitySupplierUnlimited(): self |
|
|
|
{ |
|
|
|
$this->andWhere('productFamily.availableQuantitySupplierUnlimited != 1'); |
|
|
|
return $this; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function filterAvailableQuantityNegative() :self |
|
|
|
public function filterAvailableQuantityNegative(): self |
|
|
|
{ |
|
|
|
|
|
|
|
$this->andWhere( |
|
|
|
$this->query->expr()->orX( |
|
|
|
$this->query->expr()->andX( |
|
|
|
$this->query->expr()->orX( |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily', |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure' |
|
|
|
), |
|
|
|
'productFamily.availableQuantity < 0 ' |
|
|
|
), |
|
|
|
$this->query->expr()->andX( |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct', |
|
|
|
'product.availableQuantity < 0 ' |
|
|
|
) |
|
|
|
$this->query->expr()->orX( |
|
|
|
$this->query->expr()->andX( |
|
|
|
$this->query->expr()->orX( |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily', |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure' |
|
|
|
), |
|
|
|
'productFamily.availableQuantity < 0 ' |
|
|
|
), |
|
|
|
$this->query->expr()->andX( |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct', |
|
|
|
'product.availableQuantity < 0 ' |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
$this->setParameter( |
|
|
|
'behaviorCountStockByProductFamily', |
|
|
|
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY |
|
|
|
'behaviorCountStockByProductFamily', |
|
|
|
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY |
|
|
|
); |
|
|
|
$this->setParameter('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE); |
|
|
|
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT); |
|
|
|
return $this; |
|
|
|
} |
|
|
|
|
|
|
|
public function filterAvailableQuantitySupplierNegative() :self |
|
|
|
public function filterAvailableQuantitySupplierNegative(): self |
|
|
|
{ |
|
|
|
|
|
|
|
$this->andWhere( |
|
|
|
$this->query->expr()->orX( |
|
|
|
$this->query->expr()->andX( |
|
|
|
$this->query->expr()->orX( |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily', |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure' |
|
|
|
), |
|
|
|
'productFamily.availableQuantitySupplier < 0 ' |
|
|
|
), |
|
|
|
$this->query->expr()->andX( |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct', |
|
|
|
'product.availableQuantitySupplier < 0 ' |
|
|
|
) |
|
|
|
$this->query->expr()->orX( |
|
|
|
$this->query->expr()->andX( |
|
|
|
$this->query->expr()->orX( |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily', |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure' |
|
|
|
), |
|
|
|
'productFamily.availableQuantitySupplier < 0 ' |
|
|
|
), |
|
|
|
$this->query->expr()->andX( |
|
|
|
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct', |
|
|
|
'product.availableQuantitySupplier < 0 ' |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
$this->setParameter( |
|
|
|
'behaviorCountStockByProductFamily', |
|
|
|
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY |
|
|
|
'behaviorCountStockByProductFamily', |
|
|
|
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY |
|
|
|
); |
|
|
|
$this->setParameter('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE); |
|
|
|
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT); |