addAttributeToSelect Call to undefined method M2

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





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







up vote
2
down vote

favorite












I have two custom modules and am calling one collectionfactory in other module and getting `




Call to undefined method addAttributeToSelect




Collection file look like



 class Collection extends MagentoFrameworkModelResourceModelDbCollectionAbstractCollection

/**
* Initialize resource collection
*
* @return void
*/
public function _construct()

$this->_init('VendorModuleModelHello', 'VendorModuleModelResourceModelHello');




and am calling in block



use VendorModuleModelResourceModelHelloCollectionFactory; 

class Custom extends MagentoBackendBlockWidgetGridExtended

public function __construct(
CollectionFactory $collectionFactory,
array $data =
)

$this->collectionFactory = $collectionFactory;
parent::__construct($context, $backendHelper, $data);


protected function _prepareCollection()

$collection = $this->collectionFactory->create();
$collection->addAttributeToSelect('*');
$this->setCollection($collection);
return parent::_prepareCollection();






Getting PHP Fatal error: Uncaught Error: Call to undefined method
VendorModuleModelResourceModelHelloCollection::addAttributeToSelect()








share|improve this question
















  • 1




    Try addFieldToSelect('*')
    – Prince
    Aug 8 at 10:52










  • Cool, I put it as an answer
    – Prince
    Aug 8 at 11:02

















up vote
2
down vote

favorite












I have two custom modules and am calling one collectionfactory in other module and getting `




Call to undefined method addAttributeToSelect




Collection file look like



 class Collection extends MagentoFrameworkModelResourceModelDbCollectionAbstractCollection

/**
* Initialize resource collection
*
* @return void
*/
public function _construct()

$this->_init('VendorModuleModelHello', 'VendorModuleModelResourceModelHello');




and am calling in block



use VendorModuleModelResourceModelHelloCollectionFactory; 

class Custom extends MagentoBackendBlockWidgetGridExtended

public function __construct(
CollectionFactory $collectionFactory,
array $data =
)

$this->collectionFactory = $collectionFactory;
parent::__construct($context, $backendHelper, $data);


protected function _prepareCollection()

$collection = $this->collectionFactory->create();
$collection->addAttributeToSelect('*');
$this->setCollection($collection);
return parent::_prepareCollection();






Getting PHP Fatal error: Uncaught Error: Call to undefined method
VendorModuleModelResourceModelHelloCollection::addAttributeToSelect()








share|improve this question
















  • 1




    Try addFieldToSelect('*')
    – Prince
    Aug 8 at 10:52










  • Cool, I put it as an answer
    – Prince
    Aug 8 at 11:02













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I have two custom modules and am calling one collectionfactory in other module and getting `




Call to undefined method addAttributeToSelect




Collection file look like



 class Collection extends MagentoFrameworkModelResourceModelDbCollectionAbstractCollection

/**
* Initialize resource collection
*
* @return void
*/
public function _construct()

$this->_init('VendorModuleModelHello', 'VendorModuleModelResourceModelHello');




and am calling in block



use VendorModuleModelResourceModelHelloCollectionFactory; 

class Custom extends MagentoBackendBlockWidgetGridExtended

public function __construct(
CollectionFactory $collectionFactory,
array $data =
)

$this->collectionFactory = $collectionFactory;
parent::__construct($context, $backendHelper, $data);


protected function _prepareCollection()

$collection = $this->collectionFactory->create();
$collection->addAttributeToSelect('*');
$this->setCollection($collection);
return parent::_prepareCollection();






Getting PHP Fatal error: Uncaught Error: Call to undefined method
VendorModuleModelResourceModelHelloCollection::addAttributeToSelect()








share|improve this question












I have two custom modules and am calling one collectionfactory in other module and getting `




Call to undefined method addAttributeToSelect




Collection file look like



 class Collection extends MagentoFrameworkModelResourceModelDbCollectionAbstractCollection

/**
* Initialize resource collection
*
* @return void
*/
public function _construct()

$this->_init('VendorModuleModelHello', 'VendorModuleModelResourceModelHello');




and am calling in block



use VendorModuleModelResourceModelHelloCollectionFactory; 

class Custom extends MagentoBackendBlockWidgetGridExtended

public function __construct(
CollectionFactory $collectionFactory,
array $data =
)

$this->collectionFactory = $collectionFactory;
parent::__construct($context, $backendHelper, $data);


protected function _prepareCollection()

$collection = $this->collectionFactory->create();
$collection->addAttributeToSelect('*');
$this->setCollection($collection);
return parent::_prepareCollection();






Getting PHP Fatal error: Uncaught Error: Call to undefined method
VendorModuleModelResourceModelHelloCollection::addAttributeToSelect()










share|improve this question











share|improve this question




share|improve this question










asked Aug 8 at 10:48









Daniel_12

628




628







  • 1




    Try addFieldToSelect('*')
    – Prince
    Aug 8 at 10:52










  • Cool, I put it as an answer
    – Prince
    Aug 8 at 11:02













  • 1




    Try addFieldToSelect('*')
    – Prince
    Aug 8 at 10:52










  • Cool, I put it as an answer
    – Prince
    Aug 8 at 11:02








1




1




Try addFieldToSelect('*')
– Prince
Aug 8 at 10:52




Try addFieldToSelect('*')
– Prince
Aug 8 at 10:52












Cool, I put it as an answer
– Prince
Aug 8 at 11:02





Cool, I put it as an answer
– Prince
Aug 8 at 11:02











2 Answers
2






active

oldest

votes

















up vote
2
down vote













You have to replace addAttributeToSelect('*') with addFieldToSelect('*')



addAttributeToFilter() is used to filter EAV collections.



addFieldToFilter() is used to filter Non-EAV collections.






share|improve this answer



























    up vote
    2
    down vote













    Try with



    $collection->addFieldToSelect('*');



    which is exist under




    MagentoFrameworkModelResourceModelDbCollectionAbstractCollection




    and



    addAttributeToSelect



    method exist under




    MagentoEavModelEntityCollectionAbstractCollection




    so you need to create module with EAV.






    share|improve this answer






















    • SO nice thanks :)
      – Daniel_12
      Aug 8 at 11:00










    • Welcome!! happy to help you Please accept the answer so it will help others.
      – kunj
      Aug 8 at 11:02










    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f237639%2faddattributetoselect-call-to-undefined-method-m2%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    You have to replace addAttributeToSelect('*') with addFieldToSelect('*')



    addAttributeToFilter() is used to filter EAV collections.



    addFieldToFilter() is used to filter Non-EAV collections.






    share|improve this answer
























      up vote
      2
      down vote













      You have to replace addAttributeToSelect('*') with addFieldToSelect('*')



      addAttributeToFilter() is used to filter EAV collections.



      addFieldToFilter() is used to filter Non-EAV collections.






      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        You have to replace addAttributeToSelect('*') with addFieldToSelect('*')



        addAttributeToFilter() is used to filter EAV collections.



        addFieldToFilter() is used to filter Non-EAV collections.






        share|improve this answer












        You have to replace addAttributeToSelect('*') with addFieldToSelect('*')



        addAttributeToFilter() is used to filter EAV collections.



        addFieldToFilter() is used to filter Non-EAV collections.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 8 at 11:03









        Prince

        5,9162932




        5,9162932






















            up vote
            2
            down vote













            Try with



            $collection->addFieldToSelect('*');



            which is exist under




            MagentoFrameworkModelResourceModelDbCollectionAbstractCollection




            and



            addAttributeToSelect



            method exist under




            MagentoEavModelEntityCollectionAbstractCollection




            so you need to create module with EAV.






            share|improve this answer






















            • SO nice thanks :)
              – Daniel_12
              Aug 8 at 11:00










            • Welcome!! happy to help you Please accept the answer so it will help others.
              – kunj
              Aug 8 at 11:02














            up vote
            2
            down vote













            Try with



            $collection->addFieldToSelect('*');



            which is exist under




            MagentoFrameworkModelResourceModelDbCollectionAbstractCollection




            and



            addAttributeToSelect



            method exist under




            MagentoEavModelEntityCollectionAbstractCollection




            so you need to create module with EAV.






            share|improve this answer






















            • SO nice thanks :)
              – Daniel_12
              Aug 8 at 11:00










            • Welcome!! happy to help you Please accept the answer so it will help others.
              – kunj
              Aug 8 at 11:02












            up vote
            2
            down vote










            up vote
            2
            down vote









            Try with



            $collection->addFieldToSelect('*');



            which is exist under




            MagentoFrameworkModelResourceModelDbCollectionAbstractCollection




            and



            addAttributeToSelect



            method exist under




            MagentoEavModelEntityCollectionAbstractCollection




            so you need to create module with EAV.






            share|improve this answer














            Try with



            $collection->addFieldToSelect('*');



            which is exist under




            MagentoFrameworkModelResourceModelDbCollectionAbstractCollection




            and



            addAttributeToSelect



            method exist under




            MagentoEavModelEntityCollectionAbstractCollection




            so you need to create module with EAV.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 8 at 11:34









            Sukumar Gorai

            3,7021423




            3,7021423










            answered Aug 8 at 10:58









            kunj

            2,3571420




            2,3571420











            • SO nice thanks :)
              – Daniel_12
              Aug 8 at 11:00










            • Welcome!! happy to help you Please accept the answer so it will help others.
              – kunj
              Aug 8 at 11:02
















            • SO nice thanks :)
              – Daniel_12
              Aug 8 at 11:00










            • Welcome!! happy to help you Please accept the answer so it will help others.
              – kunj
              Aug 8 at 11:02















            SO nice thanks :)
            – Daniel_12
            Aug 8 at 11:00




            SO nice thanks :)
            – Daniel_12
            Aug 8 at 11:00












            Welcome!! happy to help you Please accept the answer so it will help others.
            – kunj
            Aug 8 at 11:02




            Welcome!! happy to help you Please accept the answer so it will help others.
            – kunj
            Aug 8 at 11:02












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f237639%2faddattributetoselect-call-to-undefined-method-m2%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay