I've created a multiselect custom eav attribute based on a flat table, so I used a dataSource, for a product everything is working fine, API (SOAP & REST), display on the product page etc but I'd like to get the data inside a collection for the page_list.
Right now it's what i'm doing on the product page but if I have 500 products I have to do 500 requests to get the eav attributes data on the page_list.
$product = $this->productRepository->getById($id);
$attr = $product->getCustomAttribute("Flags");
$flagContent = [];
if ($attr && $attrValues = $attr->getValue()) {
$flag = $this->flagsCollectionFactory->create();
$flagContentObject = $flag->addFieldToFilter("flags_id", explode(",", $attrValues))->toArray();
if ($flagContentObject["items"]) {
$flagContent = $flagContentObject["items"];
}
}
return $flagContent;
Is there any way to load this "Flags" EAV attribute when I load the product collection so I don't have to do a request for every loaded products on the page_list ?
Thanks