<?php declare(strict_types=1);
namespace Okeonline\KejeLogin;
use Composer\Repository\RepositoryInterface;
use Shopware\Core\Defaults;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
class OkeonlineKejeLogin extends Plugin
{
public function activate(ActivateContext $activateContext): void
{
parent::activate($activateContext); // TODO: Change the autogenerated stub
// Test Customer with test@test.com and legacy password; strrev('password')
/** @var RepositoryInterface $customerRepository */
/** $customerRepository = $this->container->get('customer.repository');
$salutationRepository = $this->container->get('salutation.repository');
$salutationCriteria = new Criteria();
$salutationCriteria->addFilter(new EqualsFilter('salutationKey','not_specified'));
$salutation = $salutationRepository->search($salutationCriteria, $activateContext->getContext())->getEntities()->first();
$countryRepository = $this->container->get('country.repository');
$countryCriteria = new Criteria();
$countryCriteria->addFilter(new EqualsFilter('iso','NL'));
$country = $countryRepository->search($countryCriteria, $activateContext->getContext())->getEntities()->first();
$salesChannelRepository = $this->container->get('sales_channel.repository');
$salesChannelCriteria = new Criteria();
$salesChannelCriteria->addFilter(new EqualsFilter('id', Defaults::SALES_CHANNEL));
$salesChannel = $salesChannelRepository->search($salesChannelCriteria, $activateContext->getContext())->getEntities()->first();
$firstName = 'Test';
$lastName = 'Test';
$salutationId = $salutation->getId();
$countryId = $country->getId();
$salesChannelId = $salesChannel->getId();
$customerGroupId = $salesChannel->getCustomerGroupId();
$paymentMethodId = $salesChannel->getPaymentMethodId();
$addressData = [
'firstName' => $firstName,
'lastName' => $lastName,
'salutationId' => $salutationId,
'countryId' => $countryId,
'zipcode' => '8281JT',
'city' => 'Genemuiden',
'street' => 'Spoelstraat 7b',
];
$customerData = [
'email' => 'test@test.com',
'customerNumber' => '999999',
'password' => null,
'legacyPassword' => hash('sha256', 'password'),
'legacyEncoder' => 'keje_encoder',
// more required fields:
'firstName' => $firstName,
'lastName' => $lastName,
'groupId' => $customerGroupId,
'defaultPaymentMethodId' => $paymentMethodId,
'salesChannelId' => $salesChannelId,
'defaultBillingAddress' => $addressData,
'defaultShippingAddress' => $addressData,
'salutationId' => $salutationId,
];
$customerRepository->upsert([$customerData], $activateContext->getContext());**/
}
}