[Solved] How can extend customer / Shop User registration with sylius 1.10?

Adrien Asks: How can extend customer / Shop User registration with sylius 1.10?
I try to add field to customer / Shop User registration for sylius api to the path /shop/customers.

I extends Customer Model :

Code:
<?php

declare(strict_types=1);

namespace AppEntityCustomer;

use DoctrineORMMapping as ORM;
use SyliusComponentCoreModelCustomer as BaseCustomer;
use SymfonyComponentSerializerAnnotationGroups;

/**
 * @ORMEntity
 * @ORMTable(name="sylius_customer")
 */
class Customer extends BaseCustomer
{
    /**
     * @ORMColumn(type="string", length=14)
     * @Groups({"shop:customer:create"})
     */
    private $siret;

    public function getSiret(): ?string
    {
        return $this->siret;
    }

    public function setSiret(string $siret): self
    {
        $this->siret = $siret;

        return $this;
    }
}

And extends SyliusBundleApiBundleCommandRegisterShopUser :

Code:
    <?php


namespace AppControllerShopAPICommands;


use SyliusBundleApiBundleCommandRegisterShopUser;

class UserRegistrationCommand extends RegisterShopUser
{
    protected string $siret;

    public function __construct(
        string $email,
        string $plainPassword,
        string $firstName,
        string $lastName,
        string $channelCode,
        ?bool $subscribedToNewsletter,
        ?string $phoneNumber,
        string $siret
    )
    {
        parent::__construct(
            $email,
            $plainPassword,
            $firstName,
            $lastName,
            $channelCode,
            $subscribedToNewsletter,
            $phoneNumber
        );
        $this->siret = $siret;
    }

    public function siret(): string
    {
        return $this->siret;
    }

    public static function fromHttpRequestAndChannel(Request $request, ChannelInterface $channel): ChannelBasedRequestInterface
    {
        return new self($request, $channel->getCode());
    }
}

I add to the services.yaml :

Code:
AppControllerShopAPICommandsUserRegistrationCommand:
    arguments:
        $siret: "%siret%"

But when i post with Postman a json with the new field (siret) i have an error 500 with Integrity constraint violation The ‘siret’ field cannot be empty (null).

I have been looking for the solution for several days but cannot find one.

If anyone can direct me please.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.