Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding field to address #659

Open
nithiz opened this issue Jun 30, 2020 · 1 comment
Open

Adding field to address #659

nithiz opened this issue Jun 30, 2020 · 1 comment

Comments

@nithiz
Copy link

nithiz commented Jun 30, 2020

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 :)

@mamazu
Copy link
Member

mamazu commented Jun 30, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants