I need help to traverse all options in a multioption.
I use the Product-class with a new multioption-attribute called “product_properties”. I need a function to check if the optionID the user chose on the front-end matches an option in the list, and return true if a match is found.
This way I can check if e.g. the user chose “Red” as the “Color” on a product.
In pseudo-code this is what I need:
Parameters: postedOptionID, currentObjectID
-
Fetch attribute “product_properties” (multioption) on object .
-
For each option for “Color” in “product_properties”
2.1 If postedOptionID == optionID
2.1.1 return true
Thanks
I finally found a way 🙂
First get all of the object’s attribute:
$contentObjectAttributes = $contentObject->version($contentObject->attribute( ‘current_version’ ) )->contentObjectAttributes();
and then loop each and find ‘product_properties’: