What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
New field in customer table not getting saved to database
Hi Everyone,
I am trying to add a custom field to customer table , have migrated the db changes and also added a DTO and generated the transfer for the same , but my new field is not getting saved in db. Am I missing something here ? Fairly new to spryker
Comments
-
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
Hey, is the column already migrated to the database?
0 -
Yes
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
Where do you add the data for that field which you want to save?
0 -
Actually I have created a new module and extending the core customerpage module to customize the customerpage register , I have added the new field in form of my custom module and passing the same to CustomerTransfer for registration
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
Do you see you new field in the interface already?
0 -
I can see the field in my table spy_customer , also in the generated customerTransfer
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
but do you see your adjusted form?
0 -
Yes I can see that
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
ok, can you show us the code of your form, the DTO-definition and the table-schema definition file?
0 -
for my form
I have extended the Core CustomerPage/Form/RegisterForm
, overrided the buildForm method and added a field
then I have generated a propel diff by adding that field to spy_customer.schema.xml and then executed the propel:migrate command , the new field that i created is then migrated to the spy_customer table
Post That I create a new module in Pyz\Shared and added the field in transfer xml file and then executed the transfer:generate command which in turn added that field in generated\src\shared\Transfer\CustomerTransfer.php0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
have you used propel:install as well? or just the migrate?
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
how did you name the field in the form, in the transfer definition and in the schema file?
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
form and schema file should be the same; in the DTO you should NOT use lowercase for the same entity
0 -
I have just used proper:migrate , i have kept the name of field same across form , schema and DTO , its in lowercase 'type' is the field name which I am just trying out
0 -
i have just overrided the indexAction method of RegisterController to add the new form etc , i have not overrided the registerCustomer method of core , was hoping as the DTO and fields are in place it should handle the request , but all other existing fields are getting saved only my custom field is not getting saved, I tried to debug by printing the CustomerTransfer Object , I can see my custom field getting populated there but not getting saved in DB
0 -
This is in context of b2b_marketplace
0 -
Will I need to modify the customerclient or any further mapping is required ?
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
Can you please share the DTO definition?
0 -
<?xml version="1.0"?>
" xsi:schemaLocation="spryker:transfer-01 "><transfer name="Customer"> <property name="customerType" type="string"/> </transfer>
0 -
and this is the column that I added in customer.schema.xml
and triggered the same using propel:diff and propel:migrate , I can see this field is added to spy_customer table0 -
I think the issue is because propel:migrate command just created the db field but it didnot rebuild the BaseSpyCustomer class with mapping for my new field
0 -
Issue was resolved by executing propel:model:build and again propel:migrate . As a standard convention if it ok to introduce fields in spryker core tables like spy_customer ? or should we be creating our custom tables ?
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
Sorry for the late answer - thats why i use
propel:install
most of the times. it executes several propel commands one after each other0 -
Thanks , i would be using propel:install going forward . Also I a need one more help regarding overriding a core url say for example 'register' , I added my RouteProvider in RouteProviderDependency but I think it gets overried by YvesRouterPlugin() . Is there a way to efficiently override the route
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 930 Developer Corner
- 788 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random