OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce Restrict selectable shopping lists (sl) in frontend's product sl-widget

This topic contains 2 replies, has 2 voices, and was last updated by  Frank 11 months ago.

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

  • Creator
  • #40279


    # frontend
    # product-search-grid
    # in-shoppinglist-dropdown-widget

    Hi there,

    my shoppinglists have an additional property ‘owner’ (=businessUnit). I want to allow logged-in customer users to add products only to shoppinglists with the same owner
    (shoppingList.owner == product.businessOwner).

    The In-Shoppinglist-Dropdown-Widget allows to select all (!) shoppinglists, which customer user has created before:

    I want to restrict the list of selectable shoppinglists to those with the same (business)-ownership as of the product.

    I have tried to filter shoppingListsCollection in the relevant twig-template:

    Of course, this cannot work!

    TWIG does not know, what is ‘product.owner’ and what is ‘list.owner’?

    list.owner I tried to generate adding a 5th property to ‘owner’

    Although this shoppingList-property ‘owner’ is passed to the twig-template successfully (I can dump it), , it is not available as shoppingListsCollection-instance property in the javascript-section of the template.

    How I should pass both properties list.owner and product.owner to the template correctly?

    Thanks a lot for help

    I know OroShoppingListBundle/Resources/public/js/app/widget/product-shopping-list-widget.js ‘feeds’ the twig template. However I do not want to modify this js, and I think it’s not neccessary at all.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #40363
    Hryhorii Hrebiniuk
    Hryhorii Hrebiniuk


    It looks like shoppingListsCollection, that you have in the template, is instance of BaseCollection, which is created here

    It receives data from provider

    It looks like that provider needs to be extended to pass information about shopping list’s owner into the template.



    Hi there,

    thanks Hryhorii for responce, however solution was a little bit different:

    1) ShoppingList-buOwner-property:

    Investigating template
    .. product_shopping_lists.html.twig
    I found out, that I had have to exand attributes of the JS-ShoppingListCollection (id, label, is_current) to (id, label, is_current, buOwner).
    These attributes are generated by:
    I had have to override this method.

    2) Product-buOwner-property:

    Again, investigating template
    .. product_shopping_lists.html.twig
    I found out, that productShoppingLists which are used by this template are provided by:
    I had have to override this Provider, and add to twig-template a simple if-clause to filter select-options-shoppingLists in the way described above.

    And, it works.

    Thanks for recommandations

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

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

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

Yes No