私はついに方法を見つけました:)
- $ product_properties_nameは、「ezmultioption」データ型であるクラス属性の名前です。私の場合、これは「product_properties」と呼ばれ、「Product」クラスの属性です。
まず、オブジェクトのすべての属性を取得します。$ contentObjectAttributes = $ contentObject-> version($ contentObject-> attribute('current_version'))-> contentObjectAttributes();
次に、それぞれをループして、「product_properties」を見つけます。
// Loop all attributes of the object's class
foreach(array_keys($contentObjectAttributes) as $key)
{
$contentObjectAttribute = $contentObjectAttributes[$key];
$contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
$attributeIdentifier = $contentClassAttribute->attribute("identifier");
// Get 'product_properties'-attribute
if ($attributeIdentifier == $product_properties_name)
{
// Get the multioption
$multioption_list = $contentObjectAttribute->content();
// Loop all multioption lists (Color, Make, Brand etc.)
foreach($multioption_list->attribute('multioption_list') as $index => $option)
{
// Loop through this multioption and get all options (if 'Color', get 'Blue', 'Red', 'Green' etc.)
foreach($option['optionlist'] as $option)
{
$optionValue = trim($option['value']);
// if there's a match on $optionValue, do something interesting...
}
}
}
}