[Solved] Determine a list of all selected attributes of the current page in the block controller
Permalink 1 user found helpful
Hi,
does someone knows a way to get a list of all selected attributes (handle, name and value) of the current page in the block controller?
Are there classes or functions for this? Or only via SQL query?
Looking forward to answers / examples.
Greeting
LennDa
does someone knows a way to get a list of all selected attributes (handle, name and value) of the current page in the block controller?
Are there classes or functions for this? Or only via SQL query?
Looking forward to answers / examples.
Greeting
LennDa
Hi MrKDilkington,
this is exactly what I was looking for :)
To read the value of the attribute, the following conversion helped me:
Thank you very much for your help.
Greetings
LennDa
this is exactly what I was looking for :)
To read the value of the attribute, the following conversion helped me:
$attVal = $currentPageObject->getAttributeValueObject($attribute->getAttributeKeyHandle()); $attributeList[$i]['attributeValue'] = $attVal->getPlainTextValue();
Greetings
LennDa
You can try this:
- The attribute handle, attribute name, and attribute type handle will be strings.
- The attribute value could be a string, boolean, integer, object, etc.
- Because the value could be an object, and one of many different types of object (like image_file or select), you need to check its type.
- Using the attribute type handle, you could use a switch to determine what type it is and then how to process it.
*** Some of the values will be doctrine entities and using var_dump() on them will cause the page to run out of memory. When this happens, use var_dump_safe() instead.