How I can get attribute values for some attribute that are used at least in one product?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I believe you are not trying to read an attribute value of a product model, but get a list of all used values for a specific attribute.
“Plain” attributes
Plain attributes are all attributes that don’t use a
selectormultiselectfor input, but a text or textarea field or something similar.For these attributes use this:
“Option” attributes
If it is a
selectormultiselectattribute, you still need to map the option ID’s to option values. That is the case if you are getting a list of integers instead of human readable labels (e.g. for thecolorormanufacturerattribute).Direct DB query example
Depending on where you want to do this, here is an example of fetching the values without using a product collection. It is slightly more efficient.
Only use the following code in resource models, as thats where DB related code belongs.
This is meant as an educational example to show how to work with Magento’s EAV tables.