Search code examples
phpcontao

Contao: Radio/Checkbox menu - Product attribute with Options Manager


Isotope e-commerce

In the backend I've made some product attributes as Checkbox/Radio button menu and I've put the values using the Options Manager. Example: a field with name filter_farben (see picture: settings for attribute field)

On the frontend for the product if I use the generateAttribute('filter_farben') or check the raw data, I see only the ID of the field from the tl_iso_attribute_option table (34 for this - see second picture: tl_iso_attribute_option table). How can I get the label of these field (In this case 'Natur')?

Thanks!!


Solution

  • I found a solution for this strange thing. It doesn't seems to be the best one, but it's working:

       /** 
         * @param string    $id                 - returned id of attribute 
         * @param string    $field              - attribute alias 
         * @return string     $t[0]['label']   - attribute name 
         */ 
        function getAttributeNameByID($id, $field) { 
           $objAttribute=$GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$field]; 
           $t = $objAttribute->getOptionsForProductFilter(array($id)); 
           return $t[0]['label']; 
        }