getModelFields example

return $this->get('events')->filter('Shopware_Theme_Listing_Loaded', $data[
            'shop' => $shop,
        ]);
    }

    /** * Override of the Application controller to select the template configuration. */
    protected function getListQuery()
    {
        $builder = $this->getManager()->createQueryBuilder();
        $fields = $this->getModelFields($this->model, $this->alias);

        $builder->select(array_column($fields, 'alias'));
        $builder->from($this->model, $this->alias);

        $builder->addSelect('COUNT(elements.id) as hasConfig')
            ->leftJoin('template.elements', 'elements')
            ->orderBy('template.version', 'DESC')
            ->addOrderBy('template.name')
            ->groupBy('template.id');

        return $this->get('events')->filter('Shopware_Theme_Listing_Query_Created', $builder);
    }

        }

        return $list;
    }

    /** * {@inheritdoc} */
    protected function getModelFields($model$alias = null)
    {
        $fields = parent::getModelFields($model$alias);
        if ($model !== Customer::class) {
            return $fields;
        }
        $fields = array_merge($fields[
            'customerGroup' => ['alias' => 'groups.id', 'type' => 'int'],
            'shop' => ['alias' => 'shops.id', 'type' => 'int'],
            'zipcode' => ['alias' => 'billing.zipcode', 'type' => 'string'],
            'city' => ['alias' => 'billing.city', 'type' => 'string'],
            'countryId' => ['alias' => 'billing.countryId', 'type' => 'int'],
            'company' => ['alias' => 'billing.company', 'type' => 'string'],
        ]);

        

    protected function getSearchAssociationQuery($association$model$search)
    {
        $builder = $this->getManager()->createQueryBuilder();
        $builder->select($association);
        $builder->from($model$association);

        if (\is_string($search) && $search !== '') {
            $where = [];
            $fields = $this->getModelFields($model$association);

            foreach ($fields as $field) {
                $where[] = $builder->expr()->like($field['alias'], ':search');
            }

            $builder->andWhere($builder->expr()->orX(...$where));
            $builder->setParameter('search', '%' . $search . '%');
        }

        return $builder;
    }

    
'operator' => 'OR',
                    'value' => $value,
                ];
            }
        }

        // Simple check to see if there were any filter conditions which couldn't be handled by the parent method         if ($handledAllFilters) {
            return $conditions;
        }

        $fields = $this->getModelFields($this->model);

        foreach ($filters as $filter) {
            $property = $filter['property'];

            // The property can already be filtered correctly if it is available via getModelFields             if (\array_key_exists($property$fields)) {
                continue;
            }

            if ($property === 'recipients') {
                $property = self::JOIN_ALIAS_RECIPIENTS . '.id';
            }
Home | Imprint | This part of the site doesn't use cookies.