public function getFirstValueByAttributeCodeAsString(string $code, $asTitle = true)
    {
        $attributeValue = $this->getFirstValueByAttributeCode($code);

        if (!$attributeValue) {
            return "";
        }

        $field = $asTitle ? 'title' : 'value';

        return $attributeValue->$field;
    }
public function getFirstValueByAttributeCodeAsString(string $code, $asTitle = true)
    {
        $attributeValue = $this->getFirstValueByAttributeCode($code);

        if (!$attributeValue) {
            return "";
        }

        $field = $asTitle ? 'title' : 'value';

        return $attributeValue->$field;
    }
public function getFirstValueByAttributeCodeAsString ( string $ code , $ asTitle = true ) { $ attributeValue = $ this -> getFirstValueByAttributeCode ( $ code ) ; if ( ! $ attributeValue ) { return "" ; } $ field = $ asTitle ? 'title' : 'value' ; return $ attributeValue -> $ field ; }
The method should get rid of addition conditions in templates

@param string $code
@param bool $asTitle By default we should display always Title field,
but it should be also possible to use value
@return string|null
The method should get rid of addition conditions in templates