getArrayResult example


    public function getUrls(Context $routingContext, ShopContextInterface $shopContext)
    {
        if ($this->allExported) {
            return [];
        }

        $shopId = $shopContext->getShop()->getId();
        $parentId = $shopContext->getShop()->getCategory()->getId();

        $query = $this->modelManager->getRepository(Category::class)->getBlogCategoriesByParentQuery($parentId);
        $blogCategories = $query->getArrayResult();

        $blogIds = [];

        foreach ($blogCategories as $blogCategory) {
            $blogIds[] = (int) $blogCategory['id'];
        }

        if (\count($blogIds) === 0) {
            return [];
        }

        
if ($shop instanceof Shop) {
            $builder->addSelect('values')
                ->leftJoin('elements.values', 'values', 'WITH', 'values.shopId = :shopId')
                ->setParameter('shopId', $shop->getId());
        }
        if (!empty($optionNames)) {
            $builder->andWhere('elements.name IN (:optionNames)')
                ->setParameter('optionNames', $optionNames);
        }

        return $builder->getQuery()->getArrayResult();
    }

    /** * Returns the configuration sets for the passed template. * This function returns additionally the inheritance * configuration sets of the passed template. * The sets are translated automatically. * * @return array */
    public function getConfigSets(Template $template)
    {

    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.capabilityInstall', 'true'))
                ->andWhere($queryBuilder->expr()->isNull('plugin.installed'))
                ->select(['plugin.name'])
                ->getQuery()
                ->getArrayResult();

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

        return [];
    }

    /** * {@inheritdoc} */
    protected function configure()
    {
$sort = $this->Request()->getParam('sort', []);
        $filter = $this->Request()->getParam('filter', []);
        $filter[] = [
            'property' => 'mainId',
            'value' => $node,
        ];

        $repository = $this->get('models')->getRepository(Shop::class);

        $query = $repository->getListQuery($filter$sort);

        $data = $query->getArrayResult();
        $this->View()->assign([
            'success' => true, 'data' => $data, 'total' => \count($data),
        ]);
    }

    /** * Assign stored translation data. */
    public function readTranslationAction()
    {
        $type = (string) $this->Request()->getParam('type');
        
$this->View()->assign('partnerStatisticFromDate', $fromDate->format('Y-m-d'));

        // To get the right value cause 2012-02-02 is smaller than 2012-02-02 15:33:12         $toDate = $toDate->add(new DateInterval('P1D'));

        $repository = $this->get('models')->getRepository(Partner::class);

        // Get the information of the partner chart         $customerCurrencyFactor = Shopware()->Shop()->getCurrency()->getFactor();

        $dataQuery = $repository->getStatisticChartQuery($partnerId$fromDate$toDate$customerCurrencyFactor);
        $this->View()->assign('sPartnerOrderChartData', $dataQuery->getArrayResult());

        $dataQuery = $repository->getStatisticListQuery(null, null, null, $partnerId, false, $fromDate$toDate$customerCurrencyFactor);
        $this->View()->assign('sPartnerOrders', $dataQuery->getArrayResult());

        $dataQuery = $repository->getStatisticListQuery(null, null, null, $partnerId, true, $fromDate$toDate$customerCurrencyFactor);
        $this->View()->assign('sTotalPartnerAmount', $dataQuery->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY));
    }

    /** * Logout account and delete session * * @return void */
foreach ($product['details'] as &$detail) {
                    $detail['prices'] = $this->getTaxPrices(
                        $detail['prices'],
                        $product['tax']['tax']
                    );
                }
                unset($detail);
            }

            $query = $this->getManager()->createQuery('SELECT shop FROM Shopware\Models\Shop\Shop as shop');

            foreach ($query->getArrayResult() as $shop) {
                $translation = $this->translationComponent->read($shop['id'], 'article', $id);
                if (!empty($translation)) {
                    $translation['shopId'] = $shop['id'];
                    $product['translations'][$shop['id']] = $translation;
                }
            }

            if (isset($options['language']) && !empty($options['language'])) {
                $shop = $this->findEntityByConditions(Shop::class[
                    ['id' => $options['language']],
                    ['shop' => $options['language']],
                ]);

    public function getPaymentsAction()
    {
        $this->repository = $this->get('models')->getRepository(Payment::class);

        $query = $this->repository->getListQuery(null, [
            ['property' => 'payment.active', 'direction' => 'DESC'],
            ['property' => 'payment.position'],
        ]);
        $results = $query->getArrayResult();

        // Translate payments         // The standard $translationComponent->translatePayments can not be used here since the         // description may not be overridden. The field is edible and if the translation is         // shown in the edit field, there is a high chance of a user saving the translation as description.         $translator = $this->get(Shopware_Components_Translation::class)->getObjectTranslator('config_payment');
        $results = array_map(function D$payment) use ($translator) {
            return $translator->translateObjectProperty($payment, 'description', 'translatedDescription', $payment['description']);
        }$results);

        $results = $this->formatResult($results);

        
$query = $this->get('models')->getRepository(Category::class)->getListQuery(
            $filter,
            $this->Request()->getParam('sort', []),
            $this->Request()->getParam('limit'),
            $this->Request()->getParam('start'),
            false
        );

        $count = $this->get('models')->getQueryCount($query);

        $data = $query->getArrayResult();

        foreach ($data as $key => $category) {
            $data[$key]['text'] = $category['name'];
            $data[$key]['cls'] = 'folder';
            $data[$key]['childrenCount'] = (int) $category['childrenCount'];
            $data[$key]['leaf'] = empty($data[$key]['childrenCount']);
            $data[$key]['allowDrag'] = true;
            if ($preselectedNodes !== null) {
                $data[$key]['checked'] = \in_array($category['id']$preselectedNodes);
            }
        }

        

        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'))
                ->andWhere($queryBuilder->expr()->neq('plugin.active', 'true'))
                ->andWhere($queryBuilder->expr()->isNull('plugin.installed'))
                ->andWhere($queryBuilder->expr()->neq('plugin.source', ':source'))
                ->setParameter('source', 'Default')
                ->select(['plugin.name'])
                ->getQuery()
                ->getArrayResult();

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

        return [];
    }

    /** * {@inheritdoc} */
    protected function configure()
    {
$queryBuilder = $albumRepository->createQueryBuilder('alb')
                ->innerJoin('alb.settings', 'settings', Join::WITH, 'settings.createThumbnails = 1');

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

            $result = $queryBuilder->select(['alb.id'])
                ->getQuery()
                ->getArrayResult();

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

        return [];
    }

    /** * {@inheritdoc} */
    public function completeArgumentValues($argumentName, CompletionContext $context)
    {
/** * {@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 {
                $plugin = $pluginManager->getPluginByName($pluginName);
            } catch (Exception $e) {
                return [];
            }
$shopRepository = $this->getContainer()->get(ModelManager::class)->getRepository(ShopModel::class);
            $queryBuilder = $shopRepository->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');
        }

        if ($argumentName === 'analyzer') {
            $client = $this->container->get(Client::class);

            $recursive = new RecursiveIteratorIterator(
                new RecursiveArrayIterator($client->indices()->getMapping()),
                RecursiveIteratorIterator::SELF_FIRST
            );

            
->setParameter(3, $today)
                ->setParameter(4, null);

        $builder->andWhere('(banner.validTo >= ?5 OR (banner.validTo = ?6 OR banner.validTo IS NULL))')
                ->setParameter(5, $today)
                ->setParameter(6, null);

        $builder->select(['banner.id as id'])
            ->andWhere('banner.categoryId = ?1')
            ->setParameter(1, $categoryId);
        $retval = [];
        $data = $builder->getQuery()->getArrayResult();
        foreach ($data as $id) {
            $retval[] = $id['id'];
        }
        shuffle($retval);

        if ($limit > 0) {
            $retval = \array_slice($retval, 0, $limit);
        }

        return $retval;
    }
}

    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'))
                ->andWhere($queryBuilder->expr()->eq('plugin.active', 'true'))
                ->andWhere($queryBuilder->expr()->isNotNull('plugin.installed'))
                ->select(['plugin.name'])
                ->getQuery()
                ->getArrayResult();

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

        return [];
    }

    /** * {@inheritdoc} */
    protected function configure()
    {

        if ($argumentName === 'parent') {
            $queryBuilder = $this->getRepository()->createQueryBuilder('tpl');

            if ($context->getCurrentWord() !== '') {
                $queryBuilder->andWhere($queryBuilder->expr()->like('tpl.template', ':search'))
                    ->setParameter('search', addcslashes($context->getCurrentWord(), '_%') . '%');
            }

            $result = $queryBuilder->select(['tpl.template'])
                ->getQuery()
                ->getArrayResult();

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

        return [];
    }

    /** * {@inheritdoc} */
    protected function configure()
    {
Home | Imprint | This part of the site doesn't use cookies.