I am trying to get the option text from the option value in Plugin, but I can get the value but can’t get the text. May I know any way to do so?
app/code/My/Module/Plugin/DefaultItem.php
<?php
namespace MyModulePlugin;
use MagentoQuoteModelQuoteItem;
use MagentoCatalogApiProductRepositoryInterface;
class DefaultItem
{
protected $productRepository;
public function __construct(
ProductRepositoryInterface $productRepository,
)
{
$this->productRepository=$productRepository;
}
public function aroundGetItemData(MagentoCheckoutCustomerDataAbstractItem $subject, Closure $proceed, Item $item)
{
$data = $proceed($item);
$productId = $item->getProduct()->getEntityId();
$brand_value = $this->productRepository->getById($productId)->getCustomAttribute('brand')->getValue();
$atts = [
"brand" => $brand_value
];
return array_merge($data, $atts);
}
}
It only returns 13 to the frontend.. but I do want the text for this value…