OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums OroCommerce How to restrict a custom action to a specific screen?

This topic contains 4 replies, has 2 voices, and was last updated by  Mauro Chojrin 3 weeks, 5 days ago.

  • Creator
    Topic
  • #38639

    Mauro Chojrin
    Participant

    Hi:

    I created a custom action for the order entity (More on that here).

    I got it working allright (functionality wise) but I’m having a little but annoying issue: the button is showing in every screen where an order is involved, and I just want it to be shown when showing a particular order (In a URL like /admin/order/view/8).

    My configuration file looks like this:

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #38663
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    You can use preactions and preconditions to control when to display the button.
    Here is an example: https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/TranslationBundle/Resources/config/oro/actions.yml#L242-L251

    #38669

    Mauro Chojrin
    Participant

    Thanks Andrey! You’re very helpful as usual :)

    I have one question though… I’m a little confused about the purpose of the routes setting… I was under the impression this was the list of routes in which the action should be shown… is this not the case?

    #38673
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    It doesn’t work as you expected because both configs are specified, “entities” and “routes”.

    Try to remove entities:
    As the route oro_order_view is used only for an order entity, you will have the expected result.

    These conditions work as OR, not AND.
    So when the route is one of “routes” OR entity is one of “entities” the action will be shown.

    • This reply was modified 3 weeks, 5 days ago by Andrey Yatsenko Andrey Yatsenko. Reason: Clarified the issue cause
    #38679

    Mauro Chojrin
    Participant

    Got it! Thanks!

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

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No