OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform How to override parts of oro

This topic contains 14 replies, has 8 voices, and was last updated by  kiatsiong.ng 3 years, 8 months ago.

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

  • Creator
  • #36967

    Mike Kudelya


    Today i want to explain how to override parts of oro.

    • First of all create Custom (for example) namespace directory – src/Custom.
    • Create directory for bundle which you want to override – src/Custom/Bundle/FilterBundle
    • Create src/Custom/Bundle/FilterBundle/CustomFilterBundle.php which contains getParent() function. Our new bundle will know who its parent:
    • Register your bundle by creating Resources/config/oro/bundles.yml in your custom bundle with following content (this example i got from UIBundle, please change to right path)

      Now we have new bundle ready to override parent’s bundle.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Author
  • #36968

    Mike Kudelya

    To override controller, create bundle similar to CustomFilterBundle and extent it from OroDashboardBundle.

    • Create src/Custom/Bundle/DashboardBundle/Controller/DashboardController.php controller and override index action.
    • Don’t forget create file src/Custom/Bundle/DashboardBundle/Resources/config/oro/routing.yml and override oro_dashboard alias with new controller location

    Mike Kudelya

    Suppose we want to override javascript file.

    Create it, for example i want to override choice-tree-filter.js – src/Custom/Bundle/FilterBundle/Resources/public/js/filter/choice-tree-filter.js

    and register it in src/Custom/Bundle/FilterBundle/Resources/config/requirejs.yml


    Mike Kudelya

    Please run these commands after javascript changes

    and this command after yml modifications


    Mike Kudelya

    Today we are talking about service overriding. To override service you must create own bundle, after that there is two ways. The example override Oro\Bundle\ImportExportBundle\Reader\EntityReader service.


    Create your custom entity reader

    Add to src/Custom/Bundle/OroBundle/Resources/config/reader.yml these lines (‘oro_importexport.reader.entity.class’ parameter must be the same that in original class, change only path to class):

    and register reader.yml in src/Custom/Bundle/OroBundle/DependencyInjection/CustomOroExtension.php

    Second (via compiler pass):

    and register it in CustomOroBundle.php



    Hi Mike,

    I want to override the execute methode of the console command “oro:magento:initial:sync”.
    I have create bundle inherit from MagentoBundle and override InitialSyncCommand but the parent command is still executed but not mine. My bundle is loaded after the OroMagentoBundle.
    How can I solve the problem ?



    How did you declare the bundle in bundles.yml?



    Considering your documentation on https://oroinc.com/orocrm/forums/topic/how-to-override-parts-of-oro/#post-63331

    Is it possible to have 2 bundles extending the same js component? Imagine you have bundle A that adds component A and bundle B that adds component B. And you want, on both bundles, initialize the component on line-item-view.js (order contexts, like you do for product-unit-component)

    If we extend LineItemView adding on initialize method the init of new components, in both bundles, then just the one with high priority will be executed, right?

    what would be the best (and clean) approach for these case?


    Hryhorii Hrebiniuk

    Hello nevoeiro,

    Not sure that, I understood completely your case. But will try to help.

    Here’s article in Oro Book related to your question:
    See how to configure RequireJS to use another version of module.

    But it won’t work if two bundles provide their own extend for same original module. E.g.

    Only one extend will be loaded when you call require('jquery')

    To solve that issue, you need to do following:

    • the bundle with second extend has to have higher priority over bundle with first extend
    • second extend has to override map for original map. Example:
    • module with second extend has to require first extend

    If it did not help, please explain your case in more detailed examples.



    Hi Mike,

    I’m trying to replace a service using the first option you’ve suggested. It looks simple but somehow I cannot get it work. This is the service I’m trying to replace:

    So, I created a “parameters.yml” file on “MyVendor\Bundle\MyBundle\Resources\config” with the following definition:

    Then, registered it with:

    Unfortunately it always use the original service and ignores mine.
    Any hint?

    Thanks in advance.



    Hi, daniel.coelho.

    this is definition of service that you try to override: https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/WebCatalogBundle/Resources/config/services.yml#L264-L273

    There are no parameter with name “oro_web_catalog.layout.data_provider.menu_data.class“.

    So, in that case you can use, for example, service decoration approach. See https://symfony.com/doc/current/service_container/service_decoration.html.

    To comply with backward compatibility I recommend you to extend original class “Oro\Bundle\WebCatalogBundle\Layout\DataProvider\MenuDataProvider” in your custom class.



    Hi msulima,

    Thanks for your answer.
    Initially I thought about the decoration approach but the think is that I want to add logic on “prepareItemsData” method. That’s why tried to replace the service.



    Ok, lets extend from original service. You can call parent methods or not in your customization.



    I am a total noob on Symfony and Oro Platform. I want to increase the length of name for MySQL table from 30 to 64 as I encountered this error:

    The code that returns length 30 is from:

    I can override the parameters as it is defined in the services.yml:

    However, that doesn’t work because of this:

    I traced the overriding to this code:

    Given the above, how should I approach overriding the function generateIndexName()? I would appreciate any guidelines that anyone can advise.

    • This reply was modified 3 years, 8 months ago by  kiatsiong.ng.


    I managed to override the service with compiler pass.

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

The forum ‘OroPlatform’ is closed to new topics and replies.

Back to top