/**
* Get products as array according to the query, the limit and the skip. The column "is_associated"
* is also added.
*
* @param Builder $queryBuilder the query builder
* @param array $rawQuery the ids of the products that are associated
* @param int $limit the query parameters
* @param int $skip the limit of products to select for the page
* @param bool $isAssociated value of the "is associated" column that will be added
*
* @throws \Doctrine\ODM\MongoDB\MongoDBException
* @return array
*/
protected function getProductsAsArray(Builder $queryBuilder, array $rawQuery, $limit, $skip, $isAssociated)
{
$queryBuilder->find();
$queryBuilder->setQueryArray($rawQuery);
$queryBuilder->limit($limit);
$queryBuilder->skip($skip);
$query = $queryBuilder->getQuery();
$results = $query->execute()->toArray();
foreach ($results as &$product) {
$product['is_associated'] = $isAssociated;
}
return $results;
}