addAttributeToSelect Call to undefined method M2

Clash 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()
magento2 blocks collection model fatal-error
add a comment |Â
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()
magento2 blocks collection model fatal-error
1
TryaddFieldToSelect('*')
â Prince
Aug 8 at 10:52
Cool, I put it as an answer
â Prince
Aug 8 at 11:02
add a comment |Â
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()
magento2 blocks collection model fatal-error
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()
magento2 blocks collection model fatal-error
asked Aug 8 at 10:48
Daniel_12
628
628
1
TryaddFieldToSelect('*')
â Prince
Aug 8 at 10:52
Cool, I put it as an answer
â Prince
Aug 8 at 11:02
add a comment |Â
1
TryaddFieldToSelect('*')
â 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
add a comment |Â
 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.
add a comment |Â
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.
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
add a comment |Â
 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.
add a comment |Â
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.
add a comment |Â
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.
You have to replace addAttributeToSelect('*') with addFieldToSelect('*')
addAttributeToFilter() is used to filter EAV collections.
addFieldToFilter() is used to filter Non-EAV collections.
answered Aug 8 at 11:03
Prince
5,9162932
5,9162932
add a comment |Â
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
Try with
$collection->addFieldToSelect('*'); 
which is exist under
MagentoFrameworkModelResourceModelDbCollectionAbstractCollection
and
addAttributeToSelect
method exist under
MagentoEavModelEntityCollectionAbstractCollection
so you need to create module with EAV.
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Try
addFieldToSelect('*')â Prince
Aug 8 at 10:52
Cool, I put it as an answer
â Prince
Aug 8 at 11:02