Maybe with something like this (macro code, I did not test) :
/** @var Smile\ProductLabel\Model\ResourceModel\ProductLabel\CollectionFactory */
$productLabelsCollection = $productLabelCollectionFactory->create();
// Here you have all the attribute ids that are used to build product label rules.
$attributeIds = $productLabelsCollection->getAllAttributeIds();
// You should be able to iterate on these Ids.
$productEntity = $this->getCurrentProduct()->getResourceCollection()->getEntity();
foreach ($attributeIds as $attributeId) {
$attribute = $entity->getAttribute($attributeId);
if ($attribute) {
// then do the stuff you were doing previously :
$optionIds = $this->getCurrentProduct()->getCustomAttribute($attribute->getAttributeCode());
$attributesList[$attribute->getId()] = [
'id' => $attribute->getId(),
'label' => $attribute->getFrontend()->getLabel(),
'options' => ($optionIds) ? $optionIds->getValue() : ''
];
}
}
But just on attributes that might be used for label usage.
On this function : https://github.com/Smile-SA/magento2-module-product-label/blob/frontend/Block/ProductLabel/ProductLabel.php#L156
Maybe with something like this (macro code, I did not test) :