When inspecting the bellow


I get the count of 7 but items only returns 3 :

enter image description here

How Can one get all items ? in my case 7 ? Appreciate any help.

| improve this question | | | | |

As Magento had set limit in class Magento\Wishlist\CustomerData\Wishlist const SIDEBAR_ITEMS_NUMBER = 3;

So if you want to increase limit of product you have to override this class and set your custom limit as per your requirement.

| improve this answer | | | | |
  • I can see ` * @var string */ const SIDEBAR_ITEMS_NUMBER = 5;` But it doesn't work I've run setup:upgrade & php bin/magento cache:clean & php bin/magento cache:flush Clear my browser cache an still 3 on side and in the locastorage saying that I don't want to change how many it shows I want to get total for specific customer I've run sql :SELECT * FROM wishlist_item INNER JOIN wishlist ON wishlist_item.wishlist_id = wishlist.wishlist_id; it gives everything don't want to create module just to fetch this is there a way for this with ko compoment etc...? – Juliano Vargas May 25 '18 at 10:11
  • After changing CONST value log out and log in again then check does it work or not. – Sarvesh Ahuja May 25 '18 at 10:13
  • @arvesh Ahuja indeed once log out and log in again it does. How about getting all items for specific customer with ko component javascript ajax etc... ?without changing this value like: SELECT * FROM wishlist_item INNER JOIN wishlist ON wishlist_item.wishlist_id = wishlist.wishlist_id AND wishlist.customer_id = int; – Juliano Vargas May 25 '18 at 10:21
  • It can be possible but as per your question you can change count of items as per my solution or if you want total then you can override "getItems()" function and remove "setPageSize(self::SIDEBAR_ITEMS_NUMBER)" from collection of items. :) – Sarvesh Ahuja May 25 '18 at 10:26
  • I understand but no exactly what I am looking for as you may have already figured it out :) thanks – Juliano Vargas May 25 '18 at 10:31

Once you need to extend \Magento\Wishlist\CustomerData\Wishlist class into your module then try this code.

    protected function getItems()

        $collection = $this->wishlistHelper->getWishlistItemCollection();

        $items = [];
        foreach ($collection as $wishlistItem) {
            $items[] = $this->getItemData($wishlistItem);
        return $items;

Remove this ->setPageSize(self::SIDEBAR_ITEMS_NUMBER) from above code you will get total number of wishlist products.

Because const SIDEBAR_ITEMS_NUMBER = 3; is set that is why you are getting only 3 products.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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