I am using magento 2.1 C.E. I have initialized my own model with a custom table. I am trying to implement mass actions and clicking on one of the massactions, I get this error:

Exception #1 (PDOException): SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause'

Below is my massaction controller code: Index/MassAccept.php

namespace Vendor\Module\Controller\Adminhtml\Index;
use \Vendor\Module\Model\ResourceModel\Module\CollectionFactory;
use \Magento\Ui\Component\MassAction\Filter;
use \Magento\Backend\App\Action\Context;
use \Magento\Framework\View\Result\PageFactory;

class MassAccept extends \Magento\Backend\App\Action {

    protected $resultPageFactory = false;
    protected $_moduleFactory;
    protected $filter;

    public function __construct(
        Filter $filter,
        CollectionFactory $moduleFactory,
        PageFactory $resultPageFactory,
        Context $context
        ) {
        $this->filter = $filter;
        $this->_moduleFactory = $moduleFactory;
        $this->resultPageFactory = $resultPageFactory;

    public function execute() {
        // $ids = $this->getRequest()->getParams('id');
        // Create/load module model
        $model = $this->_moduleFactory->create();
        // Get collection of the loaded model using filter to get the data
        $collection = $this->filter->getCollection($model);

        foreach($collection as $item) {
            echo $item->getId();
        $resultRedirect = $this->resultRedirectFactory->create();
        return $resultRedirect;
  • pass your primary key in id of param. $this->getRequest()->getParams('primary_key'); – Rakesh Jesadiya Oct 13 '16 at 10:07
  • I am sending this from grid, but I am not able to fetch them properly. And yes, the id is getiing sent here. I am using my custom model as you can see in the code – Abhishek Dhanraj Shahdeo Oct 13 '16 at 10:10

your modele have to impliment data service and it has getId() with you id key situated in database table and then only you can get collection from $item->getId()

else you need to retrive data using proper id name like 'getBannerId()'

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.