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

                      Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

                      Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form