hasCustomerScope example


    private function isExistingEmail($value, Shop $shop$customerId = null)
    {
        $builder = $this->connection->createQueryBuilder();
        $builder->select('1');
        $builder->from('s_user');
        $builder->andWhere('email = :email');
        $builder->andWhere('accountmode != ' . Customer::ACCOUNT_MODE_FAST_LOGIN);
        $builder->setParameter('email', $value);

        if ($shop->hasCustomerScope()) {
            $builder->andWhere('subshopID = :shopId');
            $builder->setParameter('shopId', $shop->getParentId());
        }

        if ($customerId !== null) {
            $builder->andWhere('id != :userId');
            $builder->setParameter('userId', $customerId);
        }

        $id = $builder->execute()->fetch(PDO::FETCH_COLUMN);

        
if (!$token = $args->getRequest()->getCookie('slt')) {
            $session->offsetSet('auto-user', null);

            return;
        }

        $context = $this->container->get(\Shopware\Bundle\StoreFrontBundle\Service\ContextServiceInterface::class)->getShopContext();
        if ($context === null) {
            return;
        }

        if ($context->getShop()->hasCustomerScope()) {
            $parts = explode('.', $token);

            if ((int) $context->getShop()->getParentId() !== (int) $parts[1]) {
                return;
            }
        }

        if ($session->offsetGet('auto-user')) {
            return;
        }

        
Home | Imprint | This part of the site doesn't use cookies.