OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums OroCommerce What is the best way to override Product/view.html.twig (ProductBundle)?

This topic contains 1 reply, has 2 voices, and was last updated by Yevhen Shyshkin Yevhen Shyshkin 4 months ago.

  • Creator
    Topic
  • #37937
    matthew.levi12
    matthew.levi12
    Participant

    Probably there are few ways to override Oro/Bundle/ProductBundle/Resources/views/Product/view.html.twig

    However I’m not sure what would be the most recommended/advised/suggested way to do it by following Oro standards.

    Let’s say I would like to rewrite to my own bundle

    From:
    Oro/Bundle/ProductBundle/Resources/views/Product/view.html.twig

    To:
    MyCompany/Bundle/HelloWorldBundle/Resources/views/Product/view.html.twig

    Is it possible?

    P.S.: This is **not** the front-end twig file, this is the admin file.

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #37939
    Yevhen Shyshkin
    Yevhen Shyshkin
    Moderator

    Hello Matthew.

    All following recommendations are provided for OroCommerce 1.6.

    1) The easiest way to override this file it to put it to app/Resources directory at the application level – see documentation https://symfony.com/doc/2.8/templating/overriding.html.

    2) You may use bundle inheritance (i.e. set OroProductBundle as parent) and then put file at the same place in the directory structure.

    3) You may create event listener to kernel.controller event and override there _template attribute which is responsible for the path to template file.

    4) You may override whole controller together with all annotations including @Template.

    Of course there are other less trivial ways, but the first one is the most commonly used during the customization of an application.

    Please let me know if that helps.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.

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

Yes No