getIdentifierField example



        return $this->createResult($builder);
    }

    /** * @return QueryBuilder */
    protected function createQuery(SearchCriteria $criteria)
    {
        $builder = $this->entityManager->createQueryBuilder();
        $builder->select($this->getIdentifierField());
        $builder->from($criteria->entity, 'entity');
        $builder->setAlias('entity');

        return $builder;
    }

    protected function addSearchTermCondition(SearchCriteria $criteria, QueryBuilder $builder)
    {
        $this->searchBuilder->addSearchTerm($builder$criteria->term, $this->getSearchFields($criteria));
    }

    
'variant.number',
            'variant.kind',
            'variant.inStock',
            'variant.ean',
            'variant.supplierNumber',
            'variant.additionalText',
            'article.active as articleActive',
            'variant.active as variantActive',
            'supplier.id as supplierId',
            'supplier.name as supplierName',
        ]);
        $query->from(Detail::class, 'variant', $this->getIdentifierField());
        $query->leftJoin('variant.article', 'article');
        $query->leftJoin('article.supplier', 'supplier');

        return $query;
    }

    protected function getIdentifierField()
    {
        return 'variant.number';
    }

    
$query->select([
            'entity.id',
            'entity.name',
            'entity.host',
            'entity.basePath',
            'entity.baseUrl',
            'entity.default',
            'entity.active',
            'c.name as category',
            'main.name as mainShopName',
        ]);
        $query->from(Shop::class, 'entity', $this->getIdentifierField());
        $query->leftJoin('entity.category', 'c');
        $query->leftJoin('entity.main', 'main');

        return $query;
    }
}
use Shopware\Bundle\AttributeBundle\Repository\SearchCriteria;
use Shopware\Models\Premium\Premium;

class PremiumSearcher extends GenericSearcher
{
    /** * {@inheritdoc} */
    protected function createQuery(SearchCriteria $criteria)
    {
        $query = $this->entityManager->createQueryBuilder();
        $query->select($this->getIdentifierField());
        $query->from(Premium::class, 'entity');
        $query->innerJoin('entity.articleDetail', 'variant');
        $query->innerJoin('variant.article', 'article');
        $query->leftJoin('entity.shop', 's');

        return $query;
    }

    /** * @return array */
    
use Shopware\Bundle\AttributeBundle\Repository\SearchCriteria;
use Shopware\Models\Article\Detail;

class ProductSearcher extends GenericSearcher
{
    /** * {@inheritdoc} */
    protected function createQuery(SearchCriteria $criteria)
    {
        $builder = $this->entityManager->createQueryBuilder();
        $builder->select($this->getIdentifierField());
        $builder->from(Detail::class, 'entity');
        $builder->innerJoin('entity.article', 'article');

        $builder->setAlias('entity');

        return $builder;
    }

    /** * @return array */
    
use Shopware\Bundle\AttributeBundle\Repository\SearchCriteria;
use Shopware\Models\Order\Order;

class OrderSearcher extends GenericSearcher
{
    /** * {@inheritdoc} */
    protected function createQuery(SearchCriteria $criteria)
    {
        $query = $this->entityManager->createQueryBuilder();
        $query->select($this->getIdentifierField());
        $query->from(Order::class, 'entity', $this->getIdentifierField());
        $query->leftJoin('entity.payment', 'payment');
        $query->leftJoin('entity.dispatch', 'dispatch');
        $query->leftJoin('entity.shop', 'shop');
        $query->leftJoin('entity.billing', 'billing');
        $query->leftJoin('entity.customer', 'customer');
        $query->leftJoin('entity.documents', 'document');
        $query->leftJoin('billing.country', 'billingCountry');
        $query->setAlias('entity');

        return $query;
    }
'billing.department',
            'billing.street',
            'billing.zipCode',
            'billing.city',
            'billing.phone',
            'shipping.countryId as shippingCountryId',
            'billing.countryId as billingCountryId',
            'billingCountry.name as countryName',
            'orderStatus.id as orderStateId',
            'orderStatus.name as orderStateKey',
        ]);
        $query->from(Order::class, 'entity', $this->getIdentifierField());
        $query->leftJoin('entity.details', 'orderDetails');
        $query->leftJoin(Article::class, 'product', Join::WITH, 'orderDetails.articleId = product.id');
        $query->leftJoin('product.supplier', 'supplier');
        $query->leftJoin('entity.payment', 'payment');
        $query->leftJoin('entity.orderStatus', 'orderStatus');
        $query->leftJoin('entity.dispatch', 'dispatch');
        $query->leftJoin('entity.shop', 'shop');
        $query->leftJoin('entity.customer', 'customer');
        $query->leftJoin('entity.billing', 'billing');
        $query->leftJoin('entity.shipping', 'shipping');
        $query->leftJoin('billing.country', 'billingCountry');
        

    protected function createListQuery()
    {
        $query = $this->entityManager->createQueryBuilder();
        $query->select([
            'entity.id',
            'entity.title',
            'entity.active',
            'entity.displayDate',
            'author.username as authorName',
        ]);
        $query->from(Blog::class, 'entity', $this->getIdentifierField());
        $query->leftJoin('entity.author', 'author');

        return $query;
    }
}
protected $entityManager;

    public function __construct(string $entity, ModelManager $entityManager)
    {
        $this->entity = $entity;
        $this->entityManager = $entityManager;
    }

    public function getList($identifiers)
    {
        $query = $this->createListQuery();
        $query->andWhere($this->getIdentifierField() . ' IN (:ids)');
        $query->setParameter('ids', $identifiers, Connection::PARAM_STR_ARRAY);
        $data = $query->getQuery()->getArrayResult();
        $result = [];

        $identifiers = array_map(function D$identifier): string {
            return strtolower((string) $identifier);
        }$identifiers);
        $data = array_change_key_case($data, CASE_LOWER);
        $identifierFields = explode('.', $this->getIdentifierField());
        $identifierField = array_pop($identifierFields);

        

    protected function createListQuery()
    {
        $query = $this->entityManager->createQueryBuilder();
        $query->select([
            'entity.id',
            'entity.orderNumberExport',
            'variant.number',
            'article.name',
            's.name as shop',
        ]);
        $query->from(Premium::class, 'entity', $this->getIdentifierField());
        $query->innerJoin('entity.articleDetail', 'variant');
        $query->innerJoin('variant.article', 'article');
        $query->leftJoin('entity.shop', 's');

        return $query;
    }
}
use Shopware\Models\Customer\Customer;
use Shopware\Models\CustomerStream\Mapping;

class CustomerSearcher extends GenericSearcher
{
    /** * {@inheritdoc} */
    protected function createQuery(SearchCriteria $criteria)
    {
        $builder = $this->entityManager->createQueryBuilder();
        $builder->select($this->getIdentifierField());
        $builder->from(Customer::class, 'entity');
        $builder->innerJoin('entity.defaultBillingAddress', 'billing');
        $builder->innerJoin('entity.group', 'customerGroup');
        $builder->setAlias('entity');

        if ($criteria->params && $criteria->params['streamId']) {
            $builder->innerJoin(Mapping::class, 'mapping', 'WITH', 'mapping.customerId = entity.id AND mapping.streamId = :streamId');
            $builder->setParameter(':streamId', $criteria->params['streamId']);
        }

        return $builder;
    }

    protected function createListQuery()
    {
        $query = $this->entityManager->createQueryBuilder();
        $query->select([
            'entity.id',
            'entity.value',
            'entity.position',
            'option.name as optionName',
            'option.filterable',
        ]);
        $query->from(Value::class, 'entity', $this->getIdentifierField());
        $query->innerJoin('entity.option', 'option');

        return $query;
    }
}
'billing.company',
            'billing.department',
            'billing.street',
            'billing.zipcode',
            'billing.city',
            'billing.phone',
            'billingCountry.id as countryId',
            'billingCountry.name as countryName',
            'grp.id as customerGroupId',
            'grp.name as customerGroupName',
        ]);
        $query->from(Customer::class, 'entity', $this->getIdentifierField());
        $query->innerJoin('entity.defaultBillingAddress', 'billing');
        $query->innerJoin('entity.shop', 'shop');
        $query->innerJoin('billing.country', 'billingCountry');
        $query->innerJoin('entity.group', 'grp');

        return $query;
    }
}
use Shopware\Bundle\AttributeBundle\Repository\SearchCriteria;
use Shopware\Models\Property\Value;

class PropertyOptionSearcher extends GenericSearcher
{
    /** * {@inheritdoc} */
    protected function createQuery(SearchCriteria $criteria)
    {
        $query = $this->entityManager->createQueryBuilder();
        $query->select($this->getIdentifierField());
        $query->from(Value::class, 'entity');
        $query->innerJoin('entity.option', 'option');

        return $query;
    }

    /** * @return array */
    protected function getSearchFields(SearchCriteria $criteria)
    {
        
Home | Imprint | This part of the site doesn't use cookies.