custom/plugins/OkeonlineKejeLogin/src/OkeonlineKejeLogin.php line 13

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Okeonline\KejeLogin;
  3. use Composer\Repository\RepositoryInterface;
  4. use Shopware\Core\Defaults;
  5. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
  8. use Shopware\Core\Framework\Plugin;
  9. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  10. class OkeonlineKejeLogin extends Plugin
  11. {
  12.     public function activate(ActivateContext $activateContext): void
  13.     {
  14.         parent::activate($activateContext); // TODO: Change the autogenerated stub
  15.         // Test Customer with test@test.com and legacy password; strrev('password')
  16.         /** @var RepositoryInterface $customerRepository */
  17. /**        $customerRepository = $this->container->get('customer.repository');
  18.         $salutationRepository = $this->container->get('salutation.repository');
  19.         $salutationCriteria = new Criteria();
  20.         $salutationCriteria->addFilter(new EqualsFilter('salutationKey','not_specified'));
  21.         $salutation = $salutationRepository->search($salutationCriteria, $activateContext->getContext())->getEntities()->first();
  22.         $countryRepository = $this->container->get('country.repository');
  23.         $countryCriteria = new Criteria();
  24.         $countryCriteria->addFilter(new EqualsFilter('iso','NL'));
  25.         $country = $countryRepository->search($countryCriteria, $activateContext->getContext())->getEntities()->first();
  26.         $salesChannelRepository = $this->container->get('sales_channel.repository');
  27.         $salesChannelCriteria = new Criteria();
  28.         $salesChannelCriteria->addFilter(new EqualsFilter('id', Defaults::SALES_CHANNEL));
  29.         $salesChannel = $salesChannelRepository->search($salesChannelCriteria, $activateContext->getContext())->getEntities()->first();
  30.         $firstName = 'Test';
  31.         $lastName = 'Test';
  32.         $salutationId = $salutation->getId();
  33.         $countryId = $country->getId();
  34.         $salesChannelId = $salesChannel->getId();
  35.         $customerGroupId = $salesChannel->getCustomerGroupId();
  36.         $paymentMethodId = $salesChannel->getPaymentMethodId();
  37.         $addressData = [
  38.             'firstName' => $firstName,
  39.             'lastName' => $lastName,
  40.             'salutationId' => $salutationId,
  41.             'countryId' => $countryId,
  42.             'zipcode' => '8281JT',
  43.             'city' => 'Genemuiden',
  44.             'street' => 'Spoelstraat 7b',
  45.         ];
  46.         $customerData = [
  47.             'email' => 'test@test.com',
  48.             'customerNumber' => '999999',
  49.             'password' => null,
  50.             'legacyPassword' => hash('sha256', 'password'),
  51.             'legacyEncoder' => 'keje_encoder',
  52.             // more required fields:
  53.             'firstName' => $firstName,
  54.             'lastName' => $lastName,
  55.             'groupId' => $customerGroupId,
  56.             'defaultPaymentMethodId' => $paymentMethodId,
  57.             'salesChannelId' => $salesChannelId,
  58.             'defaultBillingAddress' => $addressData,
  59.             'defaultShippingAddress' => $addressData,
  60.             'salutationId' => $salutationId,
  61.         ];
  62.         $customerRepository->upsert([$customerData], $activateContext->getContext());**/
  63.     }
  64. }