Skip to content

$quote->getAllVisibleItems() giving same product data on every iteration

I have added some products in cart pragmatically when i Iterate on quote it iterates but on each iteration it is giving same product data

 $quote = $this->quoteRepository->get( $quote->getId() );
 foreach ( $quote->getAllItems() as $item ) {
    if ( $item->getProductId() == $productId ) {
                    return true;
       }
 }

Please suggest some solution what’s the issue here