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