0

I'm trying to get a product collection via ProductRepositoryInterface. The code I'm using is this:

$searchCriteria = $this->_searchCriteriaBuilder->create();
$searchResults = $this->_productRepository->getList($searchCriteria);
$products = $searchResults->getItems();

The count for $products is correct (10) however I cannot reach the products inside the $products variable. I tried with foreach $product as $key => $value: the $key is printed (I get all the ten keys) but the value is always empty.

How can I get the product attributes (sku, name, etc) from the collection?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.