/** * Define export iterator query builder * * @param integer $position Position * * @return \XLite\Model\QueryBuilder\AQueryBuilder */ protected function defineExportIteratorQueryBuilder($position) { $qb = parent::defineExportIteratorQueryBuilder($position); if ($this->isDifferential()) { $qb->andWhere('p.exported_pb = 0'); } return $qb; }
/** * Prepare certain search condition * * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare * @param array $value Condition data * @param boolean $countOnly "Count only" flag. Do not need to add "order by" clauses if only count is needed. * * @return void */ protected function prepareCndOrderBy(\Doctrine\ORM\QueryBuilder $queryBuilder, array $value, $countOnly) { list($sort, $order) = $this->getSortOrderValue($value); if ('r.bought' == $sort) { if (!$countOnly) { $queryBuilder->linkLeft('p.order_items')->linkLeft('order_items.order')->linkLeft('order.paymentStatus')->andWhere('(paymentStatus.id IS NULL OR ' . $queryBuilder->expr()->in('paymentStatus.code', \XLite\Model\Order\Status\Payment::getPaidStatuses()) . ')')->addSelect('sum(order_items.amount) as product_amount')->addOrderBy('product_amount', $order); } $value = array('translations.name', $order); } parent::prepareCndOrderBy($queryBuilder, $value, $countOnly); }
/** * Prepare certain search condition * * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare * @param array $value Condition data * @param boolean $countOnly "Count only" flag. Do not need to add "order by" clauses if only count is needed. * * @return void */ protected function prepareCndOrderBy(\Doctrine\ORM\QueryBuilder $queryBuilder, array $value, $countOnly) { if (!$countOnly) { list($sort, $order) = $this->getSortOrderValue($value); if ('r.rating' == $sort) { $queryBuilder->linkLeft('p.reviews', 'r'); $queryBuilder->addSelect('SUM(r.rating) as rsm'); $sort = 'rsm'; $queryBuilder->addOrderBy($sort, $order); } else { parent::prepareCndOrderBy($queryBuilder, $value, $countOnly); } } }
/** * Assign price range-based search condition * * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder * @param float $min Minimum * @param float $max Maximum * * @return void */ protected function assignPriceRangeCondition(\Doctrine\ORM\QueryBuilder $queryBuilder, $min, $max) { if (\XLite::isAdminZone()) { parent::assignPriceRangeCondition($queryBuilder, $min, $max); } else { $queryBuilder->leftJoin('p.classes', 'classes', 'WITH'); $cnd = \XLite\Module\CDev\VAT\Logic\Product\Tax::getInstance()->getSearchPriceCondition('p.price', 'classes'); if (isset($min)) { $queryBuilder->andWhere($cnd . ' > :minPrice')->setParameter('minPrice', doubleval($min)); } if (isset($max)) { $queryBuilder->andWhere($cnd . ' < :maxPrice')->setParameter('maxPrice', doubleval($max)); } } }
/** * Return list of handling search params * * @return array */ protected function getHandlingSearchParams() { $list = parent::getHandlingSearchParams(); $list[] = static::P_ATTRIBUTE; $list[] = static::P_FILTER; $list[] = static::P_IN_STOCK; return $list; }
/** * Add "participate sale" flag to the list of handling search params * * @return array */ protected function getHandlingSearchParams() { $params = parent::getHandlingSearchParams(); $params[] = self::P_PARTICIPATE_SALE; return $params; }
/** * Disable checking if product is up-to-date * * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder object * @param string $alias Entity alias OPTIONAL * * @return void */ protected function addDateCondition(\Doctrine\ORM\QueryBuilder $queryBuilder, $alias = null) { if (!\XLite\Core\Config::getInstance()->CDev->ProductAdvisor->cs_enabled) { parent::addDateCondition($queryBuilder, $alias); } }
/** * Define calculated price definition DQL * * @param \XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder Query builder * @param string $alias Main alias * * @return string */ protected function defineCalculatedPriceDQL(\XLite\Model\QueryBuilder\AQueryBuilder $queryBuilder, $alias) { $dql = parent::defineCalculatedPriceDQL($queryBuilder, $alias); $queryBuilder->SetParameter('saleDiscountTypePercent', \XLite\Model\Product::SALE_DISCOUNT_TYPE_PERCENT); return 'IF(' . $alias . '.participateSale = 1,' . ' IF(' . $alias . '.discountType = :saleDiscountTypePercent,' . ' ' . $dql . ' * (1 - ' . $alias . '.salePriceValue / 100),' . ' ' . $alias . '.salePriceValue' . '),' . ' ' . $dql . ')'; }