How to add new column to exitsting table symfony - orocommerce - symfony

I'm working on an orocommerce project, and it use vendor/oro/bundles/bundle_name
And in that bundle, it have an entity named "oro_customer_user", so i want to add a new column in that table using my new bundles.
I've searched a lot but still no luck.
Almost of solution say i need to fix in vendor/oro/bundles/bundle_name, which i don't want to do.
But still have some solution say i need to use DoctrineMigrationsBundle but i'm not sure about this.
https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html
Please give advice, thanks :)

Alright, so i've found the solution for orocommerce
Just use Migration and everything is gonna be fine
You can check in this link:
https://forum.oroinc.com/orocrm/orocrm-programming-questions/topic/add-custom-field-into-orocrm-entity#post-24765
The migrate you have to create manual, because i don't know how to create migrate by command line :( .
After create migrate done, you only need to run this cmd:
php app/console oro:migration:load --show-queries
Now go and check in database, its done already.
And about entity:
I still don't know how to custom it in orocommerce. It got a lot of error.

Related

Is there a way or a plugin to configure SQL Dialects as DQL in PhpStorm?

In PhpStorm, I can change global, project or directories settings with existing SQL Dialects, but is there a way to configure SQL Dialects as Symfony/DQL in PhpStorm or a way to detect that App:Panel is a valid entity, not a table? (App:Panel table name is te_panel)
I read this answer which explains that we have to add a Java plugin, because it's currently not possible to add a new SQL Dialect on PhpStorm.
As example, this is an error that PhpStorm is throwing:
The : between App and Panel is not understood. It cannot understand the table name provided (because I provide the name of the Symfony entity).
DQL is not supported.
https://youtrack.jetbrains.com/issue/WI-9948 -- watch this ticket (star/vote/comment) to get notified on any progress.
You may try and treat App:Panel as placeholder (similar to how it was described in that linked question). But I have no ideas if it will help (have not really worked with Symfony/DQL so cannot test it myself).
What I may suggest though -- threat the whole query as plain text. Yes, no syntax highlighting and stuff but will not show errors either.
How? One way by placing special comment just before the string, e.g.
->query(/** #lang text */'SELECT ...');
Or by disabling Language Injection rule for SQL altogether.
Alternatively try what has been suggested in this comment -- custom SQL detection syntax(?): https://gist.github.com/willemnviljoen/d20ad8ad0cc365a7e80744328246610f

Nelmio/Alice 2.x Symfony 3 , Loading Related Fixtures in Different Bundles

If there's already answer to my question then sorry and please point me in the right direction because I can't find anything.
Let's say I have two Bundles. Each bundle has fixures.yml file and loader file.
Loaders and fixtures are working fine when they are not depending on each other.
However when I am referencing fixtureA from fixtureB I get duplicated record in database.
E.g:
user_{1..10}:
email (unique): '<firstName()>+<randomNumber()>#gmail.com'
plainPassword: 'secret'
story_{1..10}:
user: "#user_<current()>"
title: '<word>'
When they are in separated files - duplicated row. When they are in the same file everything is ok.
Why it's being loaded twice?
I even tried this:
$objects = Fixtures::load(__DIR__ . '/fixtures.yml', $manager, ['persist_once'=>true]);
No luck.
Evey time I am trying to use user object in story fixtures alice tries to save it into db again.
Best Regards,
Robert
I did a little research and talked to people - it looks like it's a possible bug. You can learn more here:
Nelmio/Alice 2.x Duplicated Row
Also I would like to share my work around:
I wanted to keep things separated and clean. Instead of keeping all fixtures in one file in one bundle you can move it to App/DataFixtures/ORM directory. However Symfony will not look for fixtures in this directory. You can:
add path to the fixtures in console command:
doctrine:fixtures:load --fixtures=/var/www/story/app/DataFixtures/ORM
create alias for above solution
override DoctrineFixturesBundle - how to do this
I hope this will help if you have similar issue.

Active Model Serializer not render my models

I am trying to integrate Active Model Serializer to render JSON elements with relations.
I follow the documentation on this address: http://rubydoc.info/gems/active_model_serializers
I am not sure if I am doing something wrong but it looks like serializers are not working. Do I need to make more steps?
I install the gem, generate the serializer and add relation.
Can you guide me, please??
My project is in this repo:
https://github.com/dwdsolutions/argo
Best Regards
You're using the 0.9.0 version. Try to change it to 0.8.0
Alex is right, I tried using v0.9.0 earlier and was unable to get it working per the existing documentation.
The main github repo does state to use v0.8.0 if you are familiar with the gem (https://github.com/rails-api/active_model_serializers/tree/master#maintenance-please-read). At any rate, once you get it working, you shouldn't need to manually specify your serializers since they're named properly compared to your models and controllers.
i.e. you can remove the trailing option of this line:
render json: #travel, serializer: TravelSerializer
And make it just:
render json: #travel

Doctrine migration couldn`t find non-existed class

I use doc:generate-migrations-diffto generate migration classes located in lib/migrations/. You already might know, that doc:generate-migrations-... tasks create some files in tmp directory. I had some problems with it and i delete all doctrine help files from tmp dir.
And now when I execute doc:generate-migrations-diff it fails with this message: Couldn't find class ToPrfxProduct2Site, I have Product2Site class, but there is no ToPrfxProduct2Site.
Any ideas?
Ok, i figured this out. Generating of migrations is based on existing models, so first try to find models that dont exists in your schema. For me there was Product2Site, Product2SiteTable' andBaseProduct2Site` models. Just delete this files and everything will be fine.

Drupal/Drush: How to bundle a project.profile within a project.make?

Is there any way to do:
files["project.profile"][subdir] = "profiles/project"
so I get packed the installation profile on the final bundle?
This is a great page about Profiles and Drush make.
http://drupal.org/node/642116
Currently experimenting with this myself.

Resources