I have defined a custom attribute for my products, and now would like to get a list of all values I have entered for this attribute, not for a specific product, but in general.
It is a text field, it doesn't have any predefined options. Thus,
getAllOptions() on the attribute object does not work.
How do I get a list of all entered values for the attribute?
I got it to work now. You have to use the
\Magento\Catalog\Model\ResourceModel\Product\Collection, then you can alter the collection like this:
$productCollection = $this->productCollectionFactory->create()->addAttributeToSelect('attributeName')->groupByAttribute('attributeName')->load(); return $productCollection->getColumnValues('attributeName');
This returns an array of all values saved for this attribute.