|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Product;
-
- use Knp\Component\Pager\PaginatorInterface;
- use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
- use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
- use Lc\CaracoleBundle\Model\Section\SectionInterface;
- use Lc\SovBundle\Repository\AbstractRepositoryQuery;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- class ProductRepositoryQuery extends AbstractRepositoryQuery
- {
- protected bool $isJoinProductFamily =false;
-
- public function __construct(ProductRepository $repository, PaginatorInterface $paginator)
- {
- parent::__construct($repository, 'r', $paginator);
- }
- public function orderByDefault(): \Lc\SovBundle\Repository\AbstractRepositoryQuery
- {
- return $this->orderBy('position', 'ASC');
- }
-
- public function joinProductFamily():self
- {
- if (!$this->isJoinProductFamily) {
- $this->isJoinProductFamily = true;
-
- return $this
- ->innerJoin('.productFamily', 'pf');
- //$qb->addSelect('pf'); ???
- }
- return $this;
- }
-
- public function filterBySection(SectionInterface $section):self
- {
- $this->joinProductFamily();
- $this->andWhereSection('pf', $section);
- return $this;
- }
-
- public function filterIsOnline():self
- {
- $this->joinProductFamily();
- $this->andWhereStatus('pf', 1);
- $this->andWhereStatus($this->id, 1);
- return $this;
- }
-
- public function filterBehaviorCountStock() :self
- {
- $this->andWhere(
- $this->expr()->orX(
- $this->expr()->andX(
- $this->expr()->orX(
- 'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
- 'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
- ),
- 'productFamily.availableQuantity < 0 '
- ),
- $this->expr()->andX(
- 'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
- 'e.availableQuantity < 0 '
- )
- )
- );
- $this->setParameter(
- '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;
- }
-
-
- }
|