Get Wishlist product collection in Controller of Custom module Magento2How to call a model method from controller in Magento2Creating custom module in magento2 show fatal errorMagento2 - Custom Controller throws errorMagento 2 “Recoverable Error: Argument 2 passed” when trying to define model in constructorMagento 2 Custom Module Frontend ErrorMagento 2 Custom Module New Controller IssueMagento 2.1: Invoke urlBuilder->getUrl() in a controller in a custom moduleMagento 2 - Replacing an injected argument via constructor throws an errorInjecting object into a pluiginOverriding the contact form module gets the fatal error in Magento2.2.5?

Promotion comes with unexpected 24/7/365 on-call

How to generate a triangular grid from a list of points

Why can't I share a one use code with anyone else?

Why are lawsuits between the President and Congress not automatically sent to the Supreme Court

Would a "ring language" be possible?

Do high-wing aircraft represent more difficult engineering challenges than low-wing aircraft?

Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?

How to continually and organically let my readers know what time it is in my story?

301 Redirects what does ([a-z]+)-(.*) and ([0-9]+)-(.*) mean

Can I pay my credit card?

Why do galaxies collide?

When the match time is called, does the current turn end immediately?

Is there an academic word that means "to split hairs over"?

What color to choose as "danger" if the main color of my app is red

I recently started my machine learning PhD and I have absolutely no idea what I'm doing

Capital gains on stocks sold to take initial investment off the table

How can I fix the label locations on my tikzcd diagram?

Why is the A380’s with-reversers stopping distance the same as its no-reversers stopping distance?

Why does the U.S military use mercenaries?

Polynomial division: Is this trick obvious?

multiline equation inside a matrix that is a part of multiline equation

Is it possible to pass a pointer to an operator as an argument like a pointer to a function?

Was the dragon prowess intentionally downplayed in S08E04?

"Counterexample" for the Inverse function theorem



Get Wishlist product collection in Controller of Custom module Magento2


How to call a model method from controller in Magento2Creating custom module in magento2 show fatal errorMagento2 - Custom Controller throws errorMagento 2 “Recoverable Error: Argument 2 passed” when trying to define model in constructorMagento 2 Custom Module Frontend ErrorMagento 2 Custom Module New Controller IssueMagento 2.1: Invoke urlBuilder->getUrl() in a controller in a custom moduleMagento 2 - Replacing an injected argument via constructor throws an errorInjecting object into a pluiginOverriding the contact form module gets the fatal error in Magento2.2.5?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to get Wishlist product collection in Custom module controller for the new functionality. I searched in google and I got this:



Inject this class in your constructor:



protected $wishlistProvider;

public function __construct(
...
MagentoWishlistControllerWishlistProviderInterface $wishlistProvider
)
$this->wishlistProvider = $wishlistProvider;
...



and



$currentUserWishlist = $this->wishlistProvider->getWishlist();
if ($currentUserWishlist)
$wishlistItems = $currentUserWishlist->getItemCollection();



I have tried using this code. But its not working. I am getting this error:




Uncaught TypeError: Argument 3 passed to
namespacemodulenameControllerIndexIndex::__construct() must be an
instance of MagentoWishlistControllerWishlistProviderInterface,
none given, called in
/var/www/project_name/var/generation/namespace/modulename/Controller/Index/Index/Interceptor.php
on line 14




Please suggest me a way to do this. Thanks in advance!!










share|improve this question






















  • Have you remove var folder?

    – Rakesh Jesadiya
    Dec 30 '16 at 9:49






  • 1





    Just I have removed generation folder in var. I have to remove var folder fully??

    – Murali Raj
    Dec 30 '16 at 9:50











  • Try bin/magento setup:di:compile

    – lpFranz
    Mar 13 '18 at 18:06

















0















I am trying to get Wishlist product collection in Custom module controller for the new functionality. I searched in google and I got this:



Inject this class in your constructor:



protected $wishlistProvider;

public function __construct(
...
MagentoWishlistControllerWishlistProviderInterface $wishlistProvider
)
$this->wishlistProvider = $wishlistProvider;
...



and



$currentUserWishlist = $this->wishlistProvider->getWishlist();
if ($currentUserWishlist)
$wishlistItems = $currentUserWishlist->getItemCollection();



I have tried using this code. But its not working. I am getting this error:




Uncaught TypeError: Argument 3 passed to
namespacemodulenameControllerIndexIndex::__construct() must be an
instance of MagentoWishlistControllerWishlistProviderInterface,
none given, called in
/var/www/project_name/var/generation/namespace/modulename/Controller/Index/Index/Interceptor.php
on line 14




Please suggest me a way to do this. Thanks in advance!!










share|improve this question






















  • Have you remove var folder?

    – Rakesh Jesadiya
    Dec 30 '16 at 9:49






  • 1





    Just I have removed generation folder in var. I have to remove var folder fully??

    – Murali Raj
    Dec 30 '16 at 9:50











  • Try bin/magento setup:di:compile

    – lpFranz
    Mar 13 '18 at 18:06













0












0








0








I am trying to get Wishlist product collection in Custom module controller for the new functionality. I searched in google and I got this:



Inject this class in your constructor:



protected $wishlistProvider;

public function __construct(
...
MagentoWishlistControllerWishlistProviderInterface $wishlistProvider
)
$this->wishlistProvider = $wishlistProvider;
...



and



$currentUserWishlist = $this->wishlistProvider->getWishlist();
if ($currentUserWishlist)
$wishlistItems = $currentUserWishlist->getItemCollection();



I have tried using this code. But its not working. I am getting this error:




Uncaught TypeError: Argument 3 passed to
namespacemodulenameControllerIndexIndex::__construct() must be an
instance of MagentoWishlistControllerWishlistProviderInterface,
none given, called in
/var/www/project_name/var/generation/namespace/modulename/Controller/Index/Index/Interceptor.php
on line 14




Please suggest me a way to do this. Thanks in advance!!










share|improve this question














I am trying to get Wishlist product collection in Custom module controller for the new functionality. I searched in google and I got this:



Inject this class in your constructor:



protected $wishlistProvider;

public function __construct(
...
MagentoWishlistControllerWishlistProviderInterface $wishlistProvider
)
$this->wishlistProvider = $wishlistProvider;
...



and



$currentUserWishlist = $this->wishlistProvider->getWishlist();
if ($currentUserWishlist)
$wishlistItems = $currentUserWishlist->getItemCollection();



I have tried using this code. But its not working. I am getting this error:




Uncaught TypeError: Argument 3 passed to
namespacemodulenameControllerIndexIndex::__construct() must be an
instance of MagentoWishlistControllerWishlistProviderInterface,
none given, called in
/var/www/project_name/var/generation/namespace/modulename/Controller/Index/Index/Interceptor.php
on line 14




Please suggest me a way to do this. Thanks in advance!!







magento2 php module wishlist






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 30 '16 at 9:47









Murali RajMurali Raj

98313




98313












  • Have you remove var folder?

    – Rakesh Jesadiya
    Dec 30 '16 at 9:49






  • 1





    Just I have removed generation folder in var. I have to remove var folder fully??

    – Murali Raj
    Dec 30 '16 at 9:50











  • Try bin/magento setup:di:compile

    – lpFranz
    Mar 13 '18 at 18:06

















  • Have you remove var folder?

    – Rakesh Jesadiya
    Dec 30 '16 at 9:49






  • 1





    Just I have removed generation folder in var. I have to remove var folder fully??

    – Murali Raj
    Dec 30 '16 at 9:50











  • Try bin/magento setup:di:compile

    – lpFranz
    Mar 13 '18 at 18:06
















Have you remove var folder?

– Rakesh Jesadiya
Dec 30 '16 at 9:49





Have you remove var folder?

– Rakesh Jesadiya
Dec 30 '16 at 9:49




1




1





Just I have removed generation folder in var. I have to remove var folder fully??

– Murali Raj
Dec 30 '16 at 9:50





Just I have removed generation folder in var. I have to remove var folder fully??

– Murali Raj
Dec 30 '16 at 9:50













Try bin/magento setup:di:compile

– lpFranz
Mar 13 '18 at 18:06





Try bin/magento setup:di:compile

– lpFranz
Mar 13 '18 at 18:06










2 Answers
2






active

oldest

votes


















0














In other way you can get wishlist items collection.



Use factory MagentoWishlistModelResourceModelItemCollectionFactory for getting wishlist product collection and filter that by addCustomerIdFilter($customerId)



protected $_currentUserWishlistCollectionFactory ;
protected $_Customersession;
public function __construct(
MagentoWishlistModelResourceModelItemCollectionFactory $currentUserWishlistCollectionFactory,
MagentoCustomerModelSession $Customersession,
)
....
$this->_Customersession = $Customersession;
$this->_currentUserWishlistCollectionFactory = $currentUserWishlistCollectionFactory;
....



public function getcurrentUserWishlistItems()

$collection = $this->_currentUserWishlistCollectionFactory->create();
$collection->addCustomerIdFilter($this->_Customersession->getCustomerId());
return $collection;







share|improve this answer
































    0














    Try to compile your codes:



    bin/magento setup:di:compile


    Appears to me, that your error will be solved with this.






    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f152502%2fget-wishlist-product-collection-in-controller-of-custom-module-magento2%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      In other way you can get wishlist items collection.



      Use factory MagentoWishlistModelResourceModelItemCollectionFactory for getting wishlist product collection and filter that by addCustomerIdFilter($customerId)



      protected $_currentUserWishlistCollectionFactory ;
      protected $_Customersession;
      public function __construct(
      MagentoWishlistModelResourceModelItemCollectionFactory $currentUserWishlistCollectionFactory,
      MagentoCustomerModelSession $Customersession,
      )
      ....
      $this->_Customersession = $Customersession;
      $this->_currentUserWishlistCollectionFactory = $currentUserWishlistCollectionFactory;
      ....



      public function getcurrentUserWishlistItems()

      $collection = $this->_currentUserWishlistCollectionFactory->create();
      $collection->addCustomerIdFilter($this->_Customersession->getCustomerId());
      return $collection;







      share|improve this answer





























        0














        In other way you can get wishlist items collection.



        Use factory MagentoWishlistModelResourceModelItemCollectionFactory for getting wishlist product collection and filter that by addCustomerIdFilter($customerId)



        protected $_currentUserWishlistCollectionFactory ;
        protected $_Customersession;
        public function __construct(
        MagentoWishlistModelResourceModelItemCollectionFactory $currentUserWishlistCollectionFactory,
        MagentoCustomerModelSession $Customersession,
        )
        ....
        $this->_Customersession = $Customersession;
        $this->_currentUserWishlistCollectionFactory = $currentUserWishlistCollectionFactory;
        ....



        public function getcurrentUserWishlistItems()

        $collection = $this->_currentUserWishlistCollectionFactory->create();
        $collection->addCustomerIdFilter($this->_Customersession->getCustomerId());
        return $collection;







        share|improve this answer



























          0












          0








          0







          In other way you can get wishlist items collection.



          Use factory MagentoWishlistModelResourceModelItemCollectionFactory for getting wishlist product collection and filter that by addCustomerIdFilter($customerId)



          protected $_currentUserWishlistCollectionFactory ;
          protected $_Customersession;
          public function __construct(
          MagentoWishlistModelResourceModelItemCollectionFactory $currentUserWishlistCollectionFactory,
          MagentoCustomerModelSession $Customersession,
          )
          ....
          $this->_Customersession = $Customersession;
          $this->_currentUserWishlistCollectionFactory = $currentUserWishlistCollectionFactory;
          ....



          public function getcurrentUserWishlistItems()

          $collection = $this->_currentUserWishlistCollectionFactory->create();
          $collection->addCustomerIdFilter($this->_Customersession->getCustomerId());
          return $collection;







          share|improve this answer















          In other way you can get wishlist items collection.



          Use factory MagentoWishlistModelResourceModelItemCollectionFactory for getting wishlist product collection and filter that by addCustomerIdFilter($customerId)



          protected $_currentUserWishlistCollectionFactory ;
          protected $_Customersession;
          public function __construct(
          MagentoWishlistModelResourceModelItemCollectionFactory $currentUserWishlistCollectionFactory,
          MagentoCustomerModelSession $Customersession,
          )
          ....
          $this->_Customersession = $Customersession;
          $this->_currentUserWishlistCollectionFactory = $currentUserWishlistCollectionFactory;
          ....



          public function getcurrentUserWishlistItems()

          $collection = $this->_currentUserWishlistCollectionFactory->create();
          $collection->addCustomerIdFilter($this->_Customersession->getCustomerId());
          return $collection;








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 30 '16 at 10:49

























          answered Dec 30 '16 at 10:36









          Amit BeraAmit Bera

          60.6k1682181




          60.6k1682181























              0














              Try to compile your codes:



              bin/magento setup:di:compile


              Appears to me, that your error will be solved with this.






              share|improve this answer



























                0














                Try to compile your codes:



                bin/magento setup:di:compile


                Appears to me, that your error will be solved with this.






                share|improve this answer

























                  0












                  0








                  0







                  Try to compile your codes:



                  bin/magento setup:di:compile


                  Appears to me, that your error will be solved with this.






                  share|improve this answer













                  Try to compile your codes:



                  bin/magento setup:di:compile


                  Appears to me, that your error will be solved with this.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 12 '18 at 20:43









                  lpFranzlpFranz

                  380113




                  380113



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f152502%2fget-wishlist-product-collection-in-controller-of-custom-module-magento2%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                      Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                      Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?