Möchte man in einem Plugin einen User anmelden geht das so.

In diesem Beispiel sind in dem Array $userdata die Daten des Users und dieser wird mit ACCOUNT_MODE_FAST_LOGIN als Gst für eine Bestellung eingeloggt und steht anschließend auch in der s_user Tabelle.

public function setShopwareUserdata($userdata)
  {
    $customer = new Shopware\Models\Customer\Customer();
    $customer->setAccountMode(\Shopware\Models\Customer\Customer::ACCOUNT_MODE_FAST_LOGIN);
    $customer->setActive(true);
    $customer->setCustomerType(\Shopware\Models\Customer\Customer::CUSTOMER_TYPE_BUSINESS);
    $customer->setEmail($userdata['email']);
    $customer->setFirstname($userdata['firstname']);
    $customer->setLastname($userdata['lastname']);
    $salutation = 'ms';
    if ('Herr' == $userdata['salutation']) {
      $salutation = 'mr';
    }
    $customer->setSalutation($salutation);
    $customer->setRawPassword(md5('temp'));
    $customer->setShop(Shopware()->Shop());
    $customer->setLanguageSubShop(Shopware()->Shop());

    $billing = new \Shopware\Models\Customer\Address();
    $billing->setFirstname($userdata['firstname']);
    $billing->setLastname($userdata['lastname']);
    $billing->setSalutation($salutation);
    $billing->setStreet($userdata['street']);
    $billing->setZipcode($userdata['zip']);
    $billing->setCity($userdata['city']);
    $billing->setCompany($userdata['company']);
    $billing->setPhone($userdata['phone']);
    $billing->setCountry(Shopware()->Models()->getRepository(\Shopware\Models\Country\Country::class)->findOneBy(['iso' => 'DE']));
    $billing->setCustomer($customer);

    /** @var \Shopware\Bundle\AccountBundle\Service\RegisterServiceInterface $registerService */
    $registerService = Shopware()->Container()->get('shopware_account.register_service');
    /** @var \Shopware\Bundle\StoreFrontBundle\Struct\ShopContextInterface $context */
    $context = Shopware()->Container()->get('shopware_storefront.context_service')->getShopContext();
    $registerService->register($context->getShop(), $customer, $billing);

    Shopware()->Front()->Request()->setPost('email', $customer->getEmail());
    Shopware()->Front()->Request()->setPost('passwordMD5', $customer->getPassword());
    Shopware()->Modules()->Admin()->sLogin(true);
  }