Hi I am using below product collection,but it returns option id of attribute in collection my question is how to get option label rather than option id in collection. Is there any way ?
Because I am sending data to other endpoint
/**
* @return MagentoCatalogModelResourceModelProductCollection
*/
private function getProductCollection()
{
/** @var MagentoCatalogModelResourceModelProductCollection $collection */
$collection = $this->productCollectionFactory->create();
$collection
->addAttributeToSelect('*');
return $collection;
}
and I do not want to use below code to get option label in for loop,because I gets everytime get call in loop, Anyone has better option ?
$optionId = 10;
$attr = $_product->getResource()->getAttribute('color');
if ($attr->usesSource()) {
$optionText = $attr->getSource()->getOptionText($optionId);
}