In Magento 1 I sometimes used this way to pass an argument to a category, directly from the back office

Category > Custom Design tab > XML Design Update

<reference name="product_list">
    <action method="setData"><key>giftCardId</key><value>955</value></action>

Could you tell me what will be the equivalent syntax in Magento 2, Using the same way:

Category > Design > Layout Update XML

The main idea is to pass a value for a specific category, that could be retrieved in a custom module in frontend.

Edit: I know that I can add a custom category attribute to do that too, but the point is really, does an equivalent syntax exists.

  • why are you not adding this thing in your module layout xml? you can pass data in block xml and retrieve in template Commented Jul 10, 2019 at 10:39
  • @bhargavshastri because i want the magento store owner to change this parameter without my help, and it should be different for different categories
    – ffab
    Commented Jul 10, 2019 at 12:09

1 Answer 1


You can pass arguments in M2



Setting a value of css_class in the [app/code/Magento/Theme/view/frontend/layout/default.xml] layout file:

    <argument name="css_class" xsi:type="string">header links</argument>

Using the value of css_class in [app/code/Magento/Theme/view/frontend/templates/html/title.phtml]:

$cssClass = $this->hasCssClass() 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.