How we can get the latest wishlist collection for a particular login customer without cache clean in Magento2?
-
use cachable="false" in layout file– PramodCommented Dec 31, 2020 at 11:31
-
1Do not use cachable="false" that stops the cache working for any effected page. Where are you trying to get the information and how are you trying to get it? (Pages types, phtml file, ajax request etc.)– Mark ReesCommented Dec 31, 2020 at 12:19
Add a comment
|
1 Answer
Try this
protected $itemsCollection;
public function __construct(
............................................................
\Magento\Wishlist\Model\ResourceModel\Item\CollectionFactory $itemsCollection,
............................................................
) {
$this->itemsCollection = $itemsCollection;
}
public function getAllWishlistItems()
{
return $this->itemsCollection->create();
}