Coming in to trouble while getting correct data from my wishlist:
/**
@var \Magento\Wishlist\Model\Wishlist $_wishlist
@var \Magento\Customer\Model\Session $_customerSession
*/
$wishlistCollection = $this->_wishlist->loadByCustomerId($this->_customerSession->getCustomerId(), true)->getItemCollection();
foreach($wishlistCollection as $wishedItem){
/** @var \Magento\Catalog\Model\Product $_product; */
$product = $this->_product->setStoreId($wishedItem->getStoreId())->load($wishedItem->getProductId);
/** @var \Magento\Review\Model\Rating $_rating; */
$rating = $this->_rating->getEntitySummary($wishedItem->getProductId(), true);
$ratingValue = NULL;
if($rating->getSum() && $rating->getCount()) $ratingValue = $rating->getSum()/$rating->getCount();
echo $product->getName();
echo $product->getSku();
echo $product->getProductUrl();
echo $ratingValue;
}
product 1 was clone of the original product. Product 1 has rating while original has no reviews.Review to product 1 was added after dublicating.
while in the loop product name and sku are different, but url and rating values are the same, so not sure what is wrong here.