resetQueryPart example

/** * @return int */
    public function fetchCount()
    {
        /** @var QueryBuilder $query */
        $query = clone $this->query;

        // Get first column for distinct selection         $select = $query->getQueryPart('select');

        $query->resetQueryPart('orderBy');
        $query->select('COUNT(DISTINCT ' . array_shift($select) . ')');

        return $query->execute()->fetch(PDO::FETCH_COLUMN);
    }

    /** * @deprecated in 5.6, will be removed in 5.8 without replacement * * @return QueryBuilder */
    public function getQuery()
    {
return $condition->expandVariants();
        });

        $variantAlias = 'variant';
        if (empty($conditions)) {
            $this->helper->joinAvailableVariant($query);
            $variantAlias = 'availableVariant';
        }

        $query->innerJoin($variantAlias, 's_article_configurator_option_relations', 'variantOptions', 'variantOptions.article_id = ' . $variantAlias . '.id');

        $query->resetQueryPart('orderBy');
        $query->innerJoin('variantOptions', 's_article_configurator_options', 'options', 'options.id = variantOptions.option_id AND options.group_id IN (:variantGroupIds)');
        $query->addGroupBy('variantOptions.option_id');
        $query->select('variantOptions.option_id as id');
        $query->setParameter('variantGroupIds', $facet->getGroupIds(), Connection::PARAM_INT_ARRAY);
    }

    /** * @return array<int> */
    private function getFilteredValues(Criteria $criteria): array
    {
        
 {
        return $this->getFacet($facet$reverted$criteria$context);
    }

    private function getFacet(
        ImmediateDeliveryFacet $facet,
        Criteria $reverted,
        Criteria $criteria,
        ShopContextInterface $context
    ): ?BooleanFacetResult {
        $query = $this->queryBuilderFactory->createQuery($reverted$context);
        $query->resetQueryPart('orderBy');
        $query->resetQueryPart('groupBy');

        $this->variantHelper->joinVariants($query);
        if (!$query->hasState(ImmediateDeliveryConditionHandler::STATE_INCLUDES_IMMEDIATE_DELIVERY_VARIANTS)) {
            $query->andWhere('allVariants.instock >= allVariants.minpurchase');
            $query->addState(ImmediateDeliveryConditionHandler::STATE_INCLUDES_IMMEDIATE_DELIVERY_VARIANTS);
        }

        $query->select('product.id')
            ->setMaxResults(1);

        
 {
        return $this->getFacet($facet$reverted$criteria$context);
    }

    private function getFacet(
        VoteAverageFacet $facet,
        Criteria $reverted,
        Criteria $criteria,
        ShopContextInterface $context
    ): ?RadioFacetResult {
        $query = $this->queryBuilderFactory->createQuery($reverted$context);
        $query->resetQueryPart('orderBy');
        $query->resetQueryPart('groupBy');

        if (!$query->hasState(VoteAverageCondition::STATE_INCLUDES_VOTE_TABLE)) {
            $this->joinVoteAverage($context$query);
        }

        $query->groupBy('voteAverage.average');
        $query->select([
            'voteAverage.average',
            'COUNT(voteAverage.average) as count',
        ]);

        
public function generatePartialFacet(
        FacetInterface $facet,
        Criteria $reverted,
        Criteria $criteria,
        ShopContextInterface $context
    ) {
        if ($criteria->hasAttribute('product_dimensions_handled')) {
            return null;
        }

        $query = $this->queryBuilderFactory->createQuery($reverted$context);
        $query->resetQueryPart('orderBy');
        $query->resetQueryPart('groupBy');

        $this->variantHelper->joinVariants($query);

        $query->select([
            'MIN(allVariants.height) as minHeight',
            'MAX(allVariants.height) as maxHeight',
            'MIN(allVariants.weight) as minWeight',
            'MAX(allVariants.weight) as maxWeight',
            'MIN(allVariants.width) as minWidth',
            'MAX(allVariants.width) as maxWidth',
            
$fieldCriteria,
            $context
        );

        $localColumn = EntityDefinitionQueryHelper::escape($association->getMappingLocalColumn());
        $referenceColumn = EntityDefinitionQueryHelper::escape($association->getMappingReferenceColumn());

        $orderBy = '';
        $parts = $query->getQueryPart('orderBy');
        if (!empty($parts)) {
            $orderBy = ' ORDER BY ' . implode(', ', $parts);
            $query->resetQueryPart('orderBy');
        }
        // order by is handled in group_concat         $fieldCriteria->resetSorting();

        $query->select([
            'LOWER(HEX(' . $root . '.' . $localColumn . ')) as `key`',
            'GROUP_CONCAT(LOWER(HEX(' . $root . '.' . $referenceColumn . ')) ' . $orderBy . ') as `value`',
        ]);

        $query->addGroupBy($root . '.' . $localColumn);

        
's_article_configurator_option_relations',
            $tableKey,
            'variant.id = ' . $tableKey . '.article_id AND (' . $where . ')'
        );

        if (!$condition->expandVariants()) {
            return;
        }

        if (!$query->hasState('variant_group_by')) {
            $query->resetQueryPart('groupBy');
        }

        $query->addState('variant_group_by');
        $query->addGroupBy($tableKey . '.option_id');
    }

    /** * @throws RuntimeException * @throws InvalidArgumentException */
    protected function joinListingPrices(QueryBuilder $query, ShopContextInterface $context, Criteria $criteria)
    {
namespace Shopware\Bundle\OrderBundle\Service;

use Shopware\Bundle\StoreFrontBundle\Gateway\DBAL\ListProductGateway;
use Shopware\Bundle\StoreFrontBundle\Struct\ShopContextInterface;

class ConsiderInactiveProductsListProductGateway extends ListProductGateway
{
    protected function getQuery(array $numbers, ShopContextInterface $context)
    {
        $query = parent::getQuery($numbers$context);

        $query->resetQueryPart('where');
        $query->where('variant.ordernumber IN (:numbers)');

        return $query;
    }
}
 {
        return $this->getFacet($facet$reverted$criteria$context);
    }

    private function getFacet(
        ShippingFreeFacet $facet,
        Criteria $reverted,
        Criteria $criteria,
        ShopContextInterface $context
    ): ?BooleanFacetResult {
        $query = $this->queryBuilderFactory->createQuery($reverted$context);
        $query->resetQueryPart('orderBy');
        $query->resetQueryPart('groupBy');

        $query->select('product.id')
            ->andWhere('variant.shippingfree = 1')
            ->setMaxResults(1);

        $total = $query->execute()->fetch(PDO::FETCH_COLUMN);

        if ($total <= 0) {
            return null;
        }

        

        return $facet instanceof ManufacturerFacet;
    }

    public function generatePartialFacet(
        FacetInterface $facet,
        Criteria $reverted,
        Criteria $criteria,
        ShopContextInterface $context
    ) {
        $query = $this->queryBuilderFactory->createQuery($reverted$context);
        $query->resetQueryPart('groupBy');
        $query->resetQueryPart('orderBy');

        $query->groupBy('product.id');
        $query->select('DISTINCT product.supplierID as id');

        $ids = $query->execute()->fetchAll(PDO::FETCH_COLUMN);
        $ids = array_filter($ids);

        if (empty($ids)) {
            return null;
        }

        
$filterBy = $this->Request()->getParam('filterBy');
        $categoryId = $this->Request()->getParam('categoryId');

        $query = $this->getRepository()->getListingQuery($filter$filterBy$categoryId);

        $query->setFirstResult($offset)
            ->setMaxResults($limit);

        $emotions = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        $query->select('COUNT(DISTINCT emotions.id) as count')
            ->resetQueryPart('groupBy')
            ->resetQueryPart('orderBy')
            ->setFirstResult(0)
            ->setMaxResults(1);

        $count = $query->execute()->fetch(PDO::FETCH_COLUMN);

        $this->View()->assign([
            'success' => true,
            'data' => $emotions,
            'total' => (int) $count,
        ]);
    }
return $data;
    }

    public function fetchCount(): int
    {
        $query = clone $this->query;

        // get first column for distinct selection         $select = $query->getQueryPart('select');

        $query->resetQueryPart('orderBy');
        $query->select('COUNT(DISTINCT ' . array_shift($select) . ')');

        return (int) $query->executeQuery()->fetchOne();
    }

    public function getQuery(): QueryBuilder
    {
        return $this->query;
    }

    public function getOffset(): array
    {


        $query->setMaxResults($criteria->getLimit() * 6 + 1);
    }

    private function getTotalCount(Criteria $criteria, QueryBuilder $query, array $data): int
    {
        if ($criteria->getTotalCountMode() !== Criteria::TOTAL_COUNT_MODE_EXACT) {
            return \count($data);
        }

        $query->resetQueryPart('orderBy');
        $query->setMaxResults(null);
        $query->setFirstResult(0);

        $total = new QueryBuilder($this->connection);
        $total->select(['COUNT(*)'])
            ->from(sprintf('(%s) total', $query->getSQL()))
            ->setParameters($query->getParameters()$query->getParameterTypes());

        return (int) $total->executeQuery()->fetchOne();
    }

    


        return $this->propertyGateway->getList(
            $valueIds,
            $context,
            $filterGroupIds
        );
    }

    private function rebuildQuery(QueryBuilder $query): void
    {
        $query->resetQueryPart('orderBy');
        $query->resetQueryPart('groupBy');
        $query->innerJoin('product', 's_filter_articles', 'productProperty', 'productProperty.articleID = product.id');
        $query->innerJoin('product', 's_filter', 'propertySet', 'propertySet.id = product.filtergroupID');
        $query->groupBy('productProperty.valueID');
        $query->select('productProperty.valueID as id');

        $query->addSelect('product.filtergroupID as filterGroupId');
        $query->orderBy('propertySet.position');
    }

    /** * @return array<int> */
$clone->resetQueries();

        $query = new QueryBuilder($this->connection);

        // If an aggregation is to be created on a to many association that is already stored as a filter.         // The association is therefore referenced twice in the query and would have to be created as a sub-join in each case.         // But since only the filters are considered, the association is referenced only once.         // In this case we add the aggregation field as path to the criteria builder and the join group builder will consider this path for the sub-join logic         $paths = array_filter([$this->findToManyPath($aggregation$definition)]);

        $query = $this->criteriaQueryBuilder->build($query$definition$clone$context$paths);
        $query->resetQueryPart('orderBy');

        if ($criteria->getTitle()) {
            $query->setTitle($criteria->getTitle() . '::aggregation::' . $aggregation->getName());
        }

        $this->queryHelper->addIdCondition($criteria$definition$query);

        $table = $definition->getEntityName();

        if (\count($scoreCriteria->getQueries()) > 0) {
            $escapedTable = EntityDefinitionQueryHelper::escape($table);
            
Home | Imprint | This part of the site doesn't use cookies.