getSalutationId example


    public function deserialize(Config $config, EntityDefinition $definition$entity)
    {
        $deserialized = parent::deserialize($config$definition$entity);

        $deserialized = \is_array($deserialized) ? $deserialized : iterator_to_array($deserialized);

        if (!isset($deserialized['id']) && isset($deserialized['salutationKey'])) {
            $id = $this->getSalutationId($deserialized['salutationKey']);

            // if we dont find it by salutationKey, only set the id to the fallback if we dont have any other data             if (!$id && \count($deserialized) === 1) {
                $id = $this->getSalutationId('not_specified');
                unset($deserialized['salutationKey']);
            }

            if ($id) {
                $deserialized['id'] = $id;
            }
        }

        
$newsletterAccountPagelet->setCustomer($customer);
        $newsletterAccountPagelet->setNewsletterDoi(
            (bool) $this->systemConfigService->get('core.newsletter.doubleOptInRegistered', $salesChannelId)
        );

        return $newsletterAccountPagelet;
    }

    private function hydrateFromCustomer(RequestDataBag $dataBag, CustomerEntity $customer): RequestDataBag
    {
        $dataBag->set('email', $customer->getEmail());
        $dataBag->set('salutationId', $customer->getSalutationId());
        $dataBag->set('title', $customer->getTitle());
        $dataBag->set('firstName', $customer->getFirstName());
        $dataBag->set('lastName', $customer->getLastName());
        $dataBag->set(
            'zipCode',
            $customer->getDefaultShippingAddress() ? $customer->getDefaultShippingAddress()->getZipCode() : ''
        );
        $dataBag->set(
            'city',
            $customer->getDefaultShippingAddress() ? $customer->getDefaultShippingAddress()->getCity() : ''
        );
        
$repo = $this->getContainer()->get('customer.repository');

        $repo->create([$this->customerData], Context::createDefaultContext());

        return $repo->search(new Criteria([$customerId]), Context::createDefaultContext())->first();
    }

    private function validateRecipientData(NewsletterRecipientEntity $recipientEntry): void
    {
        static::assertSame($this->customerData['email']$recipientEntry->getEmail());
        static::assertSame($this->customerData['salutationId']$recipientEntry->getSalutationId());
        static::assertSame($this->customerData['title']$recipientEntry->getTitle());
        static::assertSame($this->customerData['firstName']$recipientEntry->getFirstName());
        static::assertSame($this->customerData['lastName']$recipientEntry->getLastName());
        static::assertSame($this->customerData['defaultShippingAddress']['zipcode']$recipientEntry->getZipCode());
        static::assertSame($this->customerData['defaultShippingAddress']['city']$recipientEntry->getCity());
        static::assertSame($this->customerData['defaultShippingAddress']['street']$recipientEntry->getStreet());
    }
}
static::assertTrue($response['success']);

        $customer = $this->getCustomer();

        static::assertSame($accountType$customer->getAccountType());
    }

    public function testProfileCanBeChangedWithEmptyAccountType(): void
    {
        $customer = $this->getCustomer();
        $currentSalutationId = $customer->getSalutationId();
        $salutationIds = $this->getValidSalutationIds();
        static::assertNotEmpty($salutationIds);

        $updateSalutationId = null;
        foreach ($salutationIds as $salutationId) {
            if ($currentSalutationId === $salutationId) {
                continue;
            }

            $updateSalutationId = $salutationId;

            


        return $output;
    }

    public static function transform(CustomerAddressEntity $address): array
    {
        return array_filter([
            'id' => Uuid::randomHex(),
            'company' => $address->getCompany(),
            'department' => $address->getDepartment(),
            'salutationId' => $address->getSalutationId(),
            'title' => $address->getTitle(),
            'firstName' => $address->getFirstName(),
            'lastName' => $address->getLastName(),
            'street' => $address->getStreet(),
            'zipcode' => $address->getZipcode(),
            'city' => $address->getCity(),
            'phoneNumber' => $address->getPhoneNumber(),
            'additionalAddressLine1' => $address->getAdditionalAddressLine1(),
            'additionalAddressLine2' => $address->getAdditionalAddressLine2(),
            'countryId' => $address->getCountryId(),
            'countryStateId' => $address->getCountryStateId(),
            
return $output;
    }

    public static function transform(CustomerEntity $customer): array
    {
        return [
            'customerId' => $customer->getId(),
            'email' => $customer->getEmail(),
            'firstName' => $customer->getFirstName(),
            'lastName' => $customer->getLastName(),
            'salutationId' => $customer->getSalutationId(),
            'title' => $customer->getTitle(),
            'vatIds' => $customer->getVatIds(),
            'company' => $customer->getCompany(),
            'customerNumber' => $customer->getCustomerNumber(),
            'remoteAddress' => $customer->getRemoteAddress(),
            'customFields' => $customer->getCustomFields(),
        ];
    }
}
$doubleOptIn = $this->connection->fetchAssociative($sql);

        static::assertIsArray($doubleOptIn);
        static::assertEquals($doubleOptIn['double_opt_in_registration']$doubleOptIn['doubleOptInRegistration']);
        static::assertEquals($doubleOptIn['double_opt_in_email_sent_date']$doubleOptIn['doubleOptInEmailSentDate']);
        static::assertEquals($doubleOptIn['double_opt_in_confirm_date']$doubleOptIn['doubleOptInConfirmDate']);
    }

    private function insertTestCustomer(): void
    {
        $id = Uuid::randomHex();
        $salutationId = $this->getSalutationId();

        $customer = [
            'id' => $id,
            'customerNumber' => '1337',
            'salutationId' => $salutationId,
            'firstName' => 'Max',
            'lastName' => 'Mustermann',
            'email' => 'test@example.com',
            'password' => TestDefaults::HASHED_PASSWORD,
            'defaultPaymentMethodId' => $this->getDefaultPaymentMethodId(),
            'groupId' => TestDefaults::FALLBACK_CUSTOMER_GROUP,
            


        if ($customer === null) {
            return;
        }

        if ($customer->getActiveBillingAddress() === null || $customer->getActiveShippingAddress() === null) {
            // No need to add salutation-specific errors in this case             return;
        }

        if (!$customer->getActiveBillingAddress()->getSalutationId()) {
            $errors->add(new BillingAddressSalutationMissingError($customer->getActiveBillingAddress()));

            return;
        }

        if (!$customer->getActiveShippingAddress()->getSalutationId() && $validateShipping) {
            $errors->add(new ShippingAddressSalutationMissingError($customer->getActiveShippingAddress()));
        }
    }

    public function reset(): void
    {
$salutations = $this->connection->fetchAllKeyValue('SELECT salutation_key, id FROM salutation');
        static::assertArrayHasKey(SalutationDefinition::NOT_SPECIFIED, $salutations);

        $this->createCustomer();

        /** @var CustomerEntity $customer */
        $customer = $this->customerRepository->search(
            new Criteria([$this->ids->get('customer')]),
            Context::createDefaultContext()
        )->first();

        static::assertNotNull($customer->getSalutationId());
    }

    public function testSetDefaultSalutationToNotSpecifiedWithoutExistingSalutation(): void
    {
        $this->connection->executeStatement(
            ' DELETE FROM salutation WHERE salutation_key = :salutationKey ',
            ['salutationKey' => SalutationDefinition::NOT_SPECIFIED]
        );

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