I got the attribute value 232 from the below code
$_product->getData('farben');
How I get its label from this value?
Please try this code
First you have to load the products
$_productCollection = $block->getLoadedProductCollection();
In the product listing page ,there will be a foreach loop for listing the products like this
foreach ($_productCollection as $_product)
Your code will be inside this loop.Place the below code at a place where ever you want to display the attribute label.
$_product->getResource()->getAttribute('your_attribute_code')->getFrontend()->getValue($_product);
$_product = $productObject; //get product object
$optionId = 232;
$attr = $_product->getResource()->getAttribute('attribute_code');
if ($attr->usesSource()) {
$optionText = $attr->getSource()->getOptionText($optionId);
}
echo $optionText;
$product = $this->objectFactory->get('Magento\Catalog\Model\Product')->load($product_id); $attributes = $product->getAttributes(); foreach ($attributes as $attribute) { label => __($attribute->getStoreLabel()), 'value' => $value, //attribute Value 'code' => $attribute->getAttributeCode(), //attribute Code }