ShopApiPlugin
ShopApiPlugin copied to clipboard
Adding field to address
Hey everyone,
To add a simple field to the address entity and save it with the /checkout/{token}/address i'm required to completely overwrite about 10 files. This is mostly because many classes use Sylius\ShopApiPlugin\Model\Address as a type instead of an interface. Also, this classes is not extendable since it's a final class.
These are the files i need to overwrite now to add a simple field like "houseNumber":
Command/Cart/AddressOrder.php Entity/Addressing/Address.php Factory/AddressBook/AddressViewFactory.php Handler/Cart/AddressOrderHandler.php Mapper/AddressMapper.php Mapper/AddressMapperInterface.php Model/Address.php Request/Checkout/AddressOrderRequest.php View/AddressBook/AddressView.php
Is there an easier way? If not, i think this should be changed in order to make adding fields to the address model (way) easier.
Thanks :)
Hey, thanks for using this package and reporting back on the user experience of it.
First of all: You are correct. To add one field to the address you need to change the mentioned files. I know that this is very inconvenient. The problem is that the address is such a central entity, that is used everywhere.
Second: We are aware of this problem. The API has been like this for a long time (it has already been improved). For the next step we are not sure how to proceed. We still want a distinction between command and request objects to have the HTTP Layer completely decoupled from the Sylius logic. If you have some suggestions on how to improve that feel free to contribute.
Third: My company did the same thing that you did and added the street number to the address. It is a shame that Sylius does not want this in their standard, this would make the whole situation even easier.