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 \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
     * Initialize resource collection
     * @return void
    public function _construct()
        $this->_init('Vendor\Module\Model\Hello', 'Vendor\Module\Model\ResourceModel\Hello');

and am calling in block

use Vendor\Module\Model\ResourceModel\Hello\CollectionFactory; 

    class Custom extends \Magento\Backend\Block\Widget\Grid\Extended
    public function __construct(
            CollectionFactory $collectionFactory,
            array $data = []
        ) {

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

    protected function _prepareCollection()
            $collection = $this->collectionFactory->create();
            return parent::_prepareCollection();


Getting PHP Fatal error: Uncaught Error: Call to undefined method Vendor\Module\Model\ResourceModel\Hello\Collection::addAttributeToSelect()

  • 1
    Try addFieldToSelect('*') – PЯINCƏ Aug 8 '18 at 10:52
  • Cool, I put it as an answer – PЯINCƏ Aug 8 '18 at 11:02

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

addAttributeToFilter() is used to filter EAV collections.

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


Try with


which is exist under




method exist under


so you need to create module with EAV.

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

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.