In Magento2, I understood we have to use repositories instead of collections. What I do not understand is how to add custom attributes to repository.
If I do something like this:
$searchCriteria = $this->searchCriteriaBuilder
->addFilter(ProductInterface::STATUS, Status::STATUS_ENABLED)
->addFilter(ProductInterface::VISIBILITY, array(Visibility::VISIBILITY_IN_SEARCH, Visibility::VISIBILITY_BOTH), 'in')
->create();
$products = $this->productRepositoryInterface->getList($searchCriteria);
I have a list of products, but I do not have all the attributes I need.
How can achieve this? Something like the addAttributeToSelect
in Magento 1.
addAttributeToSelect()
also exit in magento2.x ,You can use like ` $products->addAttributeToSelect('name)`