0

How we can get the latest wishlist collection for a particular login customer without cache clean in Magento2?

2
  • use cachable="false" in layout file
    – Pramod
    Commented Dec 31, 2020 at 11:31
  • 1
    Do 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 Rees
    Commented Dec 31, 2020 at 12:19

1 Answer 1

1

Try this

protected $itemsCollection;

public function __construct(
    ............................................................
    \Magento\Wishlist\Model\ResourceModel\Item\CollectionFactory $itemsCollection,
    ............................................................
) {
    $this->itemsCollection = $itemsCollection;
}

public function getAllWishlistItems()
{
    return $this->itemsCollection->create();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.