If I pull a list of products with the repository I am unable to get any custom attributes.
$searchCriteria = $this->searchCriteriaBuilder->addFilter('type_id', 'simple', 'eq')->create();
$simpleProdSearch = $this->productRepository->getList($searchCriteria);
$simpleProds = $simpleProdSearch->getItems();
foreach($simpleProds as $product)
{
$cats = $product->getCustomAttribute('category_ids'); // null
}
If I load the product by ID then it works:
foreach($simpleProds as $product)
{
$fullProduct = $this->productRepository->getById( $product->getId() );
$cats = $fullProduct->getCustomAttribute('category_ids');
}
But this loads the product twice. I am performing action on all products so I want this to be performant as possible. Can I add the category IDs to the full collection of products?