OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce block type embedded_list. How can I get the last item

This topic contains 1 reply, has 2 voices, and was last updated by  Andrey Yatsenko 6 years, 10 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
  • #31850

    thinh2010
    Participant

    Hi,
    I am working on the frontend of orocommerce. I dont know how to check the last item in embedded_list.

    this is my code:

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #31851

    Andrey Yatsenko
    Moderator

    Hello thinh2010,

    To know what item is the last you can override embeded_list_widget twig block and pass standard twig loop variable to the child block
    here the reference for the variable https://twig.sensiolabs.org/doc/2.x/tags/for.html

    To make it working just insert below block type to your twig template

    This is the copy of the original block from https://github.com/orocrm/customer-portal/blob/master/src/Oro/Bundle/FrontendBundle/Resources/views/layouts/blank/layout.html.twig#L197-L237

    The only thing I changed is line 29, with

    Here I passed the standard loop variable that available in any {% for %} loop from the parent block to the child with {% do block|merge_context(context) %}

    Now you can use loop variable in the child items template of embedded_list block

    That it!

Viewing 1 replies (of 1 total)

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

Back to top