1

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>
</reference>

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.

2
  • why are you not adding this thing in your module layout xml? you can pass data in block xml and retrieve in template 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
    Jul 10, 2019 at 12:09

1 Answer 1

0

You can pass arguments in M2

https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/xml-instructions.html#argument

Example:

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

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

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.