Given a Magento\Catalog\Api\Data\ProductInterface $product and string $attributeCode of an arbitrary attribute, I can access the attribute value, using:


This is the Service Contract variant of $product->getData($attributeCode)

Now I'm looking for an equivalent to $product->getAttributeText($attributeCode) because the attribute might be a "select" or "multiselect" type.

Is it possible, using only Service Contracts? If I load the attribute, using Magento\Catalog\Api\ProductAttributeRepositoryInterface, I could use $attribute->getFrontend()->getValue(), but this is again using implementation details that are not part of the Service Contract API.

  • Mate I'm afraid you're going to face a lot of walls trying to go the Service Contracts way for everything you want to achieve. But I'm with you, we should do some PR Jun 6, 2016 at 8:45
  • True, but I'm going to continue to ask these questions when I'm hitting walls, and if it's just to highlight, where the API is incomplete, especially when it's about the catalog. Jun 6, 2016 at 8:49
  • Totally agree with you Jun 6, 2016 at 8:51


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy