Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    How to get all the options of a custom attribute in magento 2

    Today I will share with you that How you can get all the options of a custom attribute by the attribute code in Magento 2.

    First of all, you need to create an instance of EavConfig. I have shared the code that I used in a controller file, but you can use it in Helper or block according to your need.

    after that, write the function to get the all the options of the attribute,

    $arr now contains all the options as you can see below. The “value” is the option id and “label” is the frontend label of the option.

    You can use this wherever you need to display options of a custom attribute. I have used this on Magento version 2.2.1 but this will work for other versions as well.

    For any queries, you can comment below.

    . . .


    Add Your Comment

    Be the first to comment.

    Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again