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..
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
Hey, is the column already migrated to the database?
Yes
Where do you add the data for that field which you want to save?
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
Do you see you new field in the interface already?
I can see the field in my table spy_customer , also in the generated customerTransfer
but do you see your adjusted form?
Yes I can see that
ok, can you show us the code of your form, the DTO-definition and the table-schema definition file?
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.php
have you used propel:install as well? or just the migrate?
how did you name the field in the form, in the transfer definition and in the schema file?
form and schema file should be the same; in the DTO you should NOT use lowercase for the same entity
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
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
This is in context of b2b_marketplace
Will I need to modify the customerclient or any further mapping is required ?
Can you please share the DTO definition?
<?xml version="1.0"?>
"
xsi:schemaLocation="spryker:transfer-01 ">
<transfer name="Customer"> <property name="customerType" type="string"/> </transfer>
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 table
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
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 ?
Sorry for the late answer - thats why i use propel:install
most of the times. it executes several propel commands one after each other
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