protected function prepareReviewsProduct(array &$reviews)
    {
        if (!empty($reviews)) {

            $users = array();
            foreach ($reviews as $review) {
                $users[] = $review['user_id'];
            }

            $ratings = null;

            if (!empty($users)) {
                $ratings = $this->rating->getByUser($this->data_product['product_id'], $users);
            }

            foreach ($reviews as &$review) {

                $rating = array('rating' => 0);

                if (isset($ratings[$review['user_id']]['rating'])) {
                    $rating['rating'] = $ratings[$review['user_id']]['rating'];
                }

                $review['rating'] = $rating['rating'];
                $review['rating_formatted'] = $this->render('common/rating/static', array('rating' => $rating));
            }
        }
    }
protected function prepareReviewsProduct(array &$reviews)
    {
        if (!empty($reviews)) {

            $users = array();
            foreach ($reviews as $review) {
                $users[] = $review['user_id'];
            }

            $ratings = null;

            if (!empty($users)) {
                $ratings = $this->rating->getByUser($this->data_product['product_id'], $users);
            }

            foreach ($reviews as &$review) {

                $rating = array('rating' => 0);

                if (isset($ratings[$review['user_id']]['rating'])) {
                    $rating['rating'] = $ratings[$review['user_id']]['rating'];
                }

                $review['rating'] = $rating['rating'];
                $review['rating_formatted'] = $this->render('common/rating/static', array('rating' => $rating));
            }
        }
    }
protected function prepareReviewsProduct ( array & $ reviews ) { if ( ! empty ( $ reviews ) ) { $ users = array ( ) ; foreach ( $ reviews as $ review ) { $ users [ ] = $ review [ 'user_id' ] ; } $ ratings = null ; if ( ! empty ( $ users ) ) { $ ratings = $ this -> rating -> getByUser ( $ this -> data_product [ 'product_id' ] , $ users ) ; } foreach ( $ reviews as & $ review ) { $ rating = array ( 'rating' => 0 ) ; if ( isset ( $ ratings [ $ review [ 'user_id' ] ] [ 'rating' ] ) ) { $ rating [ 'rating' ] = $ ratings [ $ review [ 'user_id' ] ] [ 'rating' ] ; } $ review [ 'rating' ] = $ rating [ 'rating' ] ; $ review [ 'rating_formatted' ] = $ this -> render ( 'common/rating/static' , array ( 'rating' => $ rating ) ) ; } } }
Prepare an array of reviews
@param array $reviews
Prepare an array of reviews