getDBALQueryBuilder example


    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $locale = $this->container->get(ModelManager::class)->getRepository(Locale::class)->findOneByLocale($input->getArgument('locale'));
        if (!$locale) {
            $output->writeln('<error>Provided locale not found</error>');

            return 1;
        }

        $filteredQueryBuilder = $this->container->get(ModelManager::class)->getDBALQueryBuilder();
        $localeQueryBuilder = $this->container->get(ModelManager::class)->getDBALQueryBuilder();

        $statement = $localeQueryBuilder
            ->select('DISTINCT CONCAT(s.namespace, s.name) as hash')
            ->from('s_core_snippets', 's')
            ->where('s.localeID = :locale')
            ->setParameter('locale', $locale->getId())
            ->execute()
        ;

        $localeSnippets = $statement->fetchAll();

        
/** * Exports form labels from the database into a php file containing an array * * @param \Shopware\Models\Shop\Locale $locale * @param string $dir * * @throws Exception */
    protected function exportFormLabels(OutputInterface $output$locale$dir)
    {
        $formQueryBuilder = $this->container->get(\Shopware\Components\Model\ModelManager::class)->getDBALQueryBuilder();
        $statement = $formQueryBuilder
            ->select('form.name AS name', 'form.label AS label', 'form.description AS description')
            ->from('s_core_config_forms', 'form')
            ->leftJoin(
                'form',
                's_core_config_form_translations',
                'trans',
                ' form.id = trans.form_id AND trans.locale_id = :localeId'
            )
            ->where('trans.form_id IS NULL')
            ->andWhere('form.name IS NOT NULL')
            


    /** * Returns the available property values */
    public function getPropertyValuesAction()
    {
        $propertyGroupId = $this->Request()->getParam('propertyGroupId');
        $searchValue = $this->Request()->getParam('query');
        $optionId = $this->Request()->getParam('optionId');

        $builder = $this->get('models')->getDBALQueryBuilder();
        $builder->select([
            'filterValues.id AS id',
            'filterValues.value AS value',
            'filterOptions.id AS optionId', ])
            ->from('s_filter_values', 'filterValues')
            ->innerJoin('filterValues', 's_filter_options', 'filterOptions', 'filterValues.optionID = filterOptions.id')
            ->innerJoin('filterOptions', 's_filter_relations', 'filterRelations', 'filterOptions.id = filterRelations.optionID')
            ->innerJoin('filterRelations', 's_filter', 'filter', 'filter.id = filterRelations.groupID AND (filter.id = :propertyGroupId)')
            ->setParameter('propertyGroupId', $propertyGroupId);

        if (!empty($searchValue)) {
            
$this->manager = $this->get('models');
        }

        return $this->manager;
    }

    /** * Returns the query builder to fetch all available stores */
    private function getShopsQueryBuilder(): QueryBuilder
    {
        $builder = $this->getManager()->getDBALQueryBuilder();
        $builder->select([
            's.id',
            's.name',
            'c.currency',
            'c.name AS currencyName',
            'c.templateChar AS currencyChar',
            '(c.symbol_position = 16) currencyAtEnd',
        ])
            ->from('s_core_shops', 's')
            ->leftJoin('s', 's_core_currencies', 'c', 's.currency_id = c.id')
            ->orderBy('s.default', 'desc')
            
Home | Imprint | This part of the site doesn't use cookies.