OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Programming Questions Creating multiple entities in one go programmatically

This topic contains 5 replies, has 2 voices, and was last updated by  Spurgeon 9 years, 6 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #24899

    Spurgeon
    Participant

    Hi,

    We need to create around 200 User groups namely XYZ0001, XYZ0002 and so on..

    I guess this can be achieved easily pro grammatically with a for loop, in a action function called by a controller.

    Guess that this can be a modification or overriding User Bundle’s GroupController.php to include a custom action function and by implementing appropriate routes.

    Could some one kindly point me to / help with the details as to how to implement this and what the code can be?

    Thanks!
    warm regards
    Spurgeon

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #24900

    Yevhen Shyshkin
    Participant

    Hello, spurgeonbj.

    Well, you can do that in controller – you can look at demo data fixture for example

    But it would be better to create data fixture for that and load it from console – this way you can easily reuse it and have all changes in one place.

    #24901

    Spurgeon
    Participant

    Hi Yevhen,

    Greetings!
    Thanks a ton for the quick & kind response and for the pointer to the best practice. Will do as you suggest!

    Warm regards and gratitude,
    Spurgeon

    #24902

    Spurgeon
    Participant

    Hi @Yevhen,

    Greetings!

    After saving our custom fixtures to lets say to vendor/oro/crm/src/OroCRM/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadMyGroupData.php

    how to load this from console?

    is it using

    ?

    How to load only this fixture, I dont want to add other demo data or loose other data.

    Thank you!
    warm regards
    Spurgeon

    #24903

    Yevhen Shyshkin
    Participant

    > How to load only this fixture, I dont want to add other demo data or loose other data.

    1) You can put it into separate directory (probably not in Migrations), and then run doctrine:fixtures:load with your directory as option “–fixtures” and “–append” option to do not purge DB.

    2) If this fixture should be part of your regular installation, then you can move this fixture to Migration/Data/ORM directory and then run oro:migration:data:load to load your fixture.

    #24904

    Spurgeon
    Participant

    Hi Yehven,

    Greetings!

    Thanks a lot for the quick and kind response.

    Warm regards and gratitude,
    Spurgeon

Viewing 5 replies - 1 through 5 (of 5 total)

The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.

Back to top