|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProductRepositoryQuery extends AbstractRepositoryQuery |
|
|
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) |
|
|
public function __construct(ProductRepository $repository, PaginatorInterface $paginator) |
|
|
{ |
|
|
{ |
|
|
parent::__construct($repository, 'product', $paginator); |
|
|
parent::__construct($repository, 'product', $paginator); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function orderByDefault(): \Lc\SovBundle\Repository\AbstractRepositoryQuery |
|
|
public function orderByDefault(): \Lc\SovBundle\Repository\AbstractRepositoryQuery |
|
|
{ |
|
|
{ |
|
|
return $this->orderBy('position', 'ASC'); |
|
|
return $this->orderBy('position', 'ASC'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function joinProductFamily():self |
|
|
|
|
|
|
|
|
public function joinProductFamily(): self |
|
|
{ |
|
|
{ |
|
|
if (!$this->isJoinProductFamily) { |
|
|
if (!$this->isJoinProductFamily) { |
|
|
$this->isJoinProductFamily = true; |
|
|
$this->isJoinProductFamily = true; |
|
|
|
|
|
|
|
|
return $this |
|
|
return $this |
|
|
->innerJoin('.productFamily', 'productFamily') |
|
|
|
|
|
->addSelect('productFamily'); |
|
|
|
|
|
|
|
|
->innerJoin('.productFamily', 'productFamily') |
|
|
|
|
|
->addSelect('productFamily'); |
|
|
} |
|
|
} |
|
|
return $this; |
|
|
return $this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function filterBySection(SectionInterface $section):self |
|
|
|
|
|
|
|
|
public function filterBySection(SectionInterface $section): self |
|
|
{ |
|
|
{ |
|
|
$this->joinProductFamilySectionProperties(false); |
|
|
$this->joinProductFamilySectionProperties(false); |
|
|
$this->andWhereSection('productFamilySectionProperties', $section); |
|
|
$this->andWhereSection('productFamilySectionProperties', $section); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function filterIsOnline():self |
|
|
|
|
|
|
|
|
public function filterIsOnline(): self |
|
|
{ |
|
|
{ |
|
|
$this->joinProductFamily(); |
|
|
$this->joinProductFamily(); |
|
|
$this->andWhereStatus('productFamily', 1); |
|
|
$this->andWhereStatus('productFamily', 1); |
|
|
|
|
|
|
|
|
return $this; |
|
|
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'); |
|
|
$this->andWhere('.originProduct = 1'); |
|
|
return $this; |
|
|
return $this; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function filterIsNotAvailableQuantitySupplierUnlimited():self |
|
|
|
|
|
|
|
|
public function filterIsNotAvailableQuantitySupplierUnlimited(): self |
|
|
{ |
|
|
{ |
|
|
$this->andWhere('productFamily.availableQuantitySupplierUnlimited != 1'); |
|
|
$this->andWhere('productFamily.availableQuantitySupplierUnlimited != 1'); |
|
|
return $this; |
|
|
return $this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function filterAvailableQuantityNegative() :self |
|
|
|
|
|
|
|
|
public function filterAvailableQuantityNegative(): self |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
$this->andWhere( |
|
|
$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( |
|
|
$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('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE); |
|
|
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT); |
|
|
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT); |
|
|
return $this; |
|
|
return $this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function filterAvailableQuantitySupplierNegative() :self |
|
|
|
|
|
|
|
|
public function filterAvailableQuantitySupplierNegative(): self |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
$this->andWhere( |
|
|
$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( |
|
|
$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('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE); |
|
|
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT); |
|
|
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT); |