andWhere example


        $this->addCondition($condition$query);
    }

    private function addCondition(OrderedProductCondition $condition, QueryBuilder $query): void
    {
        $wheres = [];
        foreach ($condition->getNumbers() as $i => $number) {
            $wheres[] = 'customer.ordered_products LIKE :product' . $i;
            $query->setParameter(':product' . $i, '%|' . $number . '|%');
        }
        $query->andWhere(implode(' OR ', $wheres));
    }
}
 {
        $this->addCondition($condition$query);
    }

    private function addCondition(SearchTermCondition $condition, QueryBuilder $query): void
    {
        $searchQuery = $this->searchTermQueryBuilder->buildQuery($condition->getTerm());

        // no matching products found by the search query builder.         // add condition that the result contains no product.         if ($searchQuery === null) {
            $query->andWhere('0 = 1');

            return;
        }

        $queryString = $searchQuery->getSQL();

        $query->addSelect('searchTable.*');
        $query->addState(self::STATE_INCLUDES_RANKING);

        $query->innerJoin(
            'product',
            

    private function getConfigFields(string $languageId): array
    {
        if (isset($this->config[$languageId])) {
            return $this->config[$languageId];
        }

        $query = $this->connection->createQueryBuilder();
        $query->select('configField.field', 'configField.tokenize', 'configField.ranking', 'LOWER(HEX(config.language_id)) as language_id');
        $query->from('product_search_config', 'config');
        $query->join('config', 'product_search_config_field', 'configField', 'config.id = configField.product_search_config_id');
        $query->andWhere('config.language_id IN (:languageIds)');
        $query->andWhere('configField.searchable = 1');

        $query->setParameter('languageIds', Uuid::fromHexToBytesList([$languageId, Defaults::LANGUAGE_SYSTEM]), ArrayParameterType::STRING);

        /** @var array<int, ConfigField> $all */
        $all = $query->executeQuery()->fetchAllAssociative();

        $fields = array_filter($allfn (array $field) => $field['language_id'] === $languageId);

        if (!empty($fields)) {
            $this->config[$languageId] = $fields;

            
return [];
    }

    /** * {@inheritdoc} */
    public function completeArgumentValues($argumentName, CompletionContext $context)
    {
        if ($argumentName === 'plugin') {
            $repository = $this->getContainer()->get(ModelManager::class)->getRepository(Plugin::class);
            $queryBuilder = $repository->createQueryBuilder('plugin');
            $result = $queryBuilder->andWhere($queryBuilder->expr()->eq('plugin.capabilityEnable', 'true'))
                ->select(['plugin.name'])
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'name');
        }

        if ($argumentName === 'key') {
            $pluginName = $context->getWordAtIndex($context->getWordIndex() - 1);
            $pluginManager = $this->container->get(InstallerService::class);
            try {
                
$this->textMapping = $textMapping;
    }

    /** * {@inheritdoc} */
    public function getIterator()
    {
        $query = $this->entityManager->getConnection()->createQueryBuilder();
        $query->select(['orders.id', 'orders.id']);
        $query->from('s_order', 'orders');
        $query->andWhere('orders.id > :lastId');
        $query->setParameter(':lastId', 0);
        $query->addOrderBy('orders.id');
        $query->setMaxResults(50);

        return new LastIdQuery($query);
    }

    /** * {@inheritdoc} */
    public function getMapping()
    {
$query->from('(SELECT 1)', 'root');

            $fields = [];
            $params = ['parentId' => $parentId, 'versionId' => $versionBytes];
            foreach ($groups as $groupId) {
                $mappingAlias = 'mapping' . $groupId;
                $optionAlias = 'option' . $groupId;

                $query->innerJoin('root', 'product_option', $mappingAlias$mappingAlias . '.product_id IS NOT NULL');
                $query->innerJoin($mappingAlias, 'property_group_option', $optionAlias$optionAlias . '.id = ' . $mappingAlias . '.property_group_option_id AND ' . $optionAlias . '.property_group_id = :' . $optionAlias);
                $query->andWhere($mappingAlias . '.product_id = product.id');

                $fields[] = 'LOWER(HEX(' . $optionAlias . '.id))';

                $params[$optionAlias] = Uuid::fromHexToBytes($groupId);
            }

            $query->addSelect('CONCAT(' . implode(',', $fields) . ')');

            $sql = ' UPDATE product SET display_group = MD5( CONCAT( LOWER(HEX(product.parent_id)), ('
 {
    }

    public function processRefund(string $refundId, Context $context): void
    {
        $result = $this->connection->createQueryBuilder()
            ->select('refund.id', 'state.technical_name', 'transaction.payment_method_id')
            ->from('order_transaction_capture_refund', self::TABLE_ALIAS)
            ->innerJoin(self::TABLE_ALIAS, 'state_machine_state', 'state', 'refund.state_id = state.id')
            ->innerJoin(self::TABLE_ALIAS, 'order_transaction_capture', 'capture', 'capture.id = refund.capture_id')
            ->innerJoin(self::TABLE_ALIAS, 'order_transaction', 'transaction', 'transaction.id = capture.order_transaction_id')
            ->andWhere('refund.id = :refundId')
            ->setParameter('refundId', Uuid::fromHexToBytes($refundId))
            ->executeQuery()
            ->fetchAssociative();

        if (!$result || !\array_key_exists('technical_name', $result) || !\array_key_exists('payment_method_id', $result)) {
            throw PaymentException::unknownRefund($refundId);
        }

        if ($result['technical_name'] !== OrderTransactionCaptureRefundStates::STATE_OPEN) {
            throw PaymentException::refundInvalidTransition($refundId$result['technical_name']);
        }

        


    /** * {@inheritdoc} */
    public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'shopId') {
            $queryBuilder = $this->modelManager->getRepository(ShopModel::class)->createQueryBuilder('shop');

            if (is_numeric($context->getCurrentWord())) {
                $queryBuilder->andWhere($queryBuilder->expr()->like('shop.id', ':id'))
                    ->setParameter('id', addcslashes($context->getCurrentWord(), '%_') . '%');
            }

            $result = $queryBuilder->select(['shop.id'])
                ->addOrderBy($queryBuilder->expr()->asc('shop.id'))
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'id');
        }

        
$this->addCondition($condition$query);
    }

    private function addCondition(LengthCondition $condition, QueryBuilder $query): void
    {
        $this->variantHelper->joinVariants($query);

        $min = ':minLength' . md5(json_encode($condition, JSON_THROW_ON_ERROR));
        $max = ':maxLength' . md5(json_encode($condition, JSON_THROW_ON_ERROR));

        if ($condition->getMinLength() > 0) {
            $query->andWhere('allVariants.length >= ' . $min);
            $query->setParameter($min$condition->getMinLength());
        }

        if ($condition->getMaxLength() > 0) {
            $query->andWhere('allVariants.length <= ' . $max);
            $query->setParameter($max$condition->getMaxLength());
        }
    }
}
$this->textMapping = $textMapping;
    }

    /** * {@inheritdoc} */
    public function getIterator()
    {
        $query = $this->entityManager->getConnection()->createQueryBuilder();
        $query->select(['customer.id', 'customer.id']);
        $query->from('s_user', 'customer');
        $query->andWhere('customer.id > :lastId');
        $query->setParameter(':lastId', 0);
        $query->addOrderBy('customer.id');
        $query->setMaxResults(50);

        return new LastIdQuery($query);
    }

    /** * {@inheritdoc} */
    public function getMapping()
    {

    public function getOne($id, array $options = [])
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $builder = $this->getRepository()->getVariantDetailQuery();
        $builder->addSelect('article')
                ->andWhere('variants.id = :variantId')
                ->addOrderBy('variants.id', 'ASC')
                ->addOrderBy('customerGroup.id', 'ASC')
                ->addOrderBy('prices.from', 'ASC')
                ->setParameter('variantId', $id);

        $variant = $builder->getQuery()->getOneOrNullResult($this->getResultMode());

        if (!$variant) {
            throw new NotFoundException(sprintf('Variant by id %d not found', $id));
        }

        
continue;
            }
            $builder->leftJoin($join$this->getDqlHelper()->getPrefixForEntity($entity));
        }

        list($dql$params) = $this->getDqlHelper()->getDqlFromTokens($tokens);

        foreach ($params as $key => $value) {
            $builder->setParameter($key$value);
        }

        $builder->andWhere($dql);
        if ($orderByInfo) {
            $direction = isset($orderBy['direction']) ? $orderBy['direction'] : 'DESC';
            $field = $orderByInfo['field'];
            $builder->orderBy(strtolower($orderByInfo['entity']) . '.' . $field$direction);
        } else {
            $builder->orderBy('detail.id', 'DESC');
        }

        return $builder;
    }

    

        $builder->setParameters([
            'defaultCustomerGroup' => self::DEFAULT_CUSTOMER_GROUP,
            'customerGroup' => $customerGroupKey,
            'quantity' => self::DEFAULT_PRODUCT_QUANTITY,
            'placeholderUpTo' => self::PLACEHOLDER_UP_TO,
        ]);

        foreach ($this->Request()->getParam('filter', []) as $filter) {
            if ($filter['property'] === 'free') {
                $builder->andWhere(
                    $builder->expr()->or(
                        'details.ordernumber LIKE :free',
                        'product.name LIKE :free',
                        'supplier.name LIKE :free'
                    )
                );
                $builder->setParameter(':free', $filter['value']);
            }
        }

        $builder->setFirstResult($this->Request()->getParam('start'))
            
$this->addCondition($condition$query);
    }

    private function addCondition(WeightCondition $condition, QueryBuilder $query): void
    {
        $this->variantHelper->joinVariants($query);

        $min = ':minLength' . md5(json_encode($condition, JSON_THROW_ON_ERROR));
        $max = ':maxLength' . md5(json_encode($condition, JSON_THROW_ON_ERROR));

        if ($condition->getMinWeight() > 0) {
            $query->andWhere('allVariants.weight >= ' . $min);
            $query->setParameter($min$condition->getMinWeight());
        }

        if ($condition->getMaxWeight() > 0) {
            $query->andWhere('allVariants.weight <= ' . $max);
            $query->setParameter($max$condition->getMaxWeight());
        }
    }
}
use Shopware\Bundle\SearchBundleDBAL\QueryBuilder;

class HasNewsletterRegistrationConditionHandler implements ConditionHandlerInterface
{
    public function supports(ConditionInterface $condition)
    {
        return $condition instanceof HasNewsletterRegistrationCondition;
    }

    public function handle(ConditionInterface $condition, QueryBuilder $query)
    {
        $query->andWhere('customer.newsletter != 0');
    }
}
Home | Imprint | This part of the site doesn't use cookies.