0

I want to get the collection's count by using this method :

public function getCount()
    {
        $connection = $this->getConnection();
        $select = $connection->select();
        $select->from($this->getEntityTable(), 'COUNT(*)');
        $result = (int)$connection->fetchOne($select);
        return $result;
    }

in the file Vendor\Module\Model\ResourceModel\Item\Collection.php

I have the following error :

Fatal error: Uncaught Error: Call to undefined method Vendor\Module\Model\ResourceModel\Item\Collection::getEntityTable() in C:\xampp\htdocs\magento2\app\code\Vendor\Module\Model\ResourceModel\Item\Collection.php:31 Stack trace: #0 C:\xampp\htdocs\magento2\app\code\Vendor\Module\Block\Crud.php(43)

Am I missing something in the constructor ?

0

I solved the problem, I should call getMainTable() and not getEntityTable().

| improve this answer | |

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.