orderBy('position', 'ASC'); } public function joinProductFamily():self { if (!$this->isJoinProductFamily) { $this->isJoinProductFamily = true; return $this ->innerJoin('.productFamily', 'pf') ->addSelect('pf'); } return $this; } public function filterBySection(SectionInterface $section):self { $this->joinProductFamilySectionProperties(false); $this->andWhereSection('pfsp', $section); $this->andWhere('pfsp.status = 1'); return $this; } public function joinProductFamilySectionProperties(bool $addSelect = true): self { $this->joinProductFamily(); if (!$this->isJoinProductFamilySectionProperties) { $this->isJoinProductFamilySectionProperties = true; $this->leftJoin('pf.productFamilySectionProperties', 'pfsp'); if ($addSelect) { $this->addSelect('pfsp'); } } 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; } }