getCustomerGroupFields example



    /** * @param int[] $ids * * @return array<array<string, mixed>> */
    private function fetchCustomers(array $ids): array
    {
        $query = $this->connection->createQueryBuilder();
        $query->addSelect($this->fieldHelper->getCustomerFields());
        $query->addSelect($this->fieldHelper->getCustomerGroupFields());
        $query->addSelect($this->fieldHelper->getPaymentFields());
        $query->addSelect('(SELECT 1 FROM s_campaigns_mailaddresses campaign_mail WHERE campaign_mail.email = customer.email LIMIT 1) as __active_campaign');
        $query->from('s_user', 'customer');
        $query->where('customer.id IN (:ids)');
        $query->leftJoin('customer', 's_core_customergroups', 'customerGroup', 'customerGroup.groupkey = customer.customergroup');
        $query->leftJoin('customerGroup', 's_core_customergroups_attributes', 'customerGroupAttribute', 'customerGroupAttribute.customerGroupID = customerGroup.id');
        $query->leftJoin('customer', 's_core_paymentmeans', 'payment', 'payment.id = customer.paymentID');
        $query->leftJoin('payment', 's_core_paymentmeans_attributes', 'paymentAttribute', 'payment.id = paymentAttribute.paymentmeanID');
        $query->leftJoin('customer', 's_user_attributes', 'customerAttribute', 'customer.id = customerAttribute.userID');
        $query->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY);

        
$groups = $this->getList([$key]);

        return array_shift($groups);
    }

    /** * {@inheritdoc} */
    public function getList(array $keys)
    {
        $query = $this->connection->createQueryBuilder();
        $query->select($this->fieldHelper->getCustomerGroupFields());

        $query->from('s_core_customergroups', 'customerGroup')
            ->leftJoin('customerGroup', 's_core_customergroups_attributes', 'customerGroupAttribute', 'customerGroupAttribute.customerGroupID = customerGroup.id')
            ->where('customerGroup.groupkey IN (:keys)')
            ->setParameter(':keys', $keys, Connection::PARAM_STR_ARRAY);

        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        $customerGroups = [];
        foreach ($data as $group) {
            $key = (string) $group['__customerGroup_groupkey'];
            

    private function getShops(array $ids): array
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->addSelect($this->fieldHelper->getShopFields())
            ->addSelect($this->fieldHelper->getCurrencyFields())
            ->addSelect($this->fieldHelper->getTemplateFields())
            ->addSelect($this->fieldHelper->getLocaleFields())
            ->addSelect($this->fieldHelper->getCustomerGroupFields())
            ->addSelect($this->fieldHelper->getCategoryFields())
            ->addSelect($this->fieldHelper->getMediaFields());

        $query->from('s_core_shops', 'shop')
            ->leftJoin('shop', 's_core_shops_attributes', 'shopAttribute', 'shopAttribute.shopID = shop.id')
            ->leftJoin('shop', 's_core_currencies', 'currency', 'currency.id = shop.currency_id')
            ->leftJoin('shop', 's_core_templates', 'template', 'shop.template_id = template.id')
            ->leftJoin('shop', 's_core_locales', 'locale', 'locale.id = shop.locale_id')
            ->leftJoin('shop', 's_core_customergroups', 'customerGroup', 'customerGroup.id = shop.customer_group_id')
            ->leftJoin('customerGroup', 's_core_customergroups_attributes', 'customerGroupAttribute', 'customerGroupAttribute.customerGroupID = customerGroup.id')
            ->leftJoin('shop', 's_categories', 'category', 'category.id = shop.category_id')
            
Home | Imprint | This part of the site doesn't use cookies.