Steps to reproduce

  1. Go to Reports -> By Customers

  2. Enter customer name in search box

  3. Click on search

It will show

Fatal Error: Column not found: 1054 Unknown column 'customer_name' in 'where clause', query was: SELECT COUNT(DISTINCT detail.customer_id) FROM review AS main_table

I have found this bug in all Magento 2.1.x. And posted issue on github


Have anyone idea about this?


This issue still continues in Magento 2.1.8, 2.2 and 2.2 EE

  • Yes , alternative we have to use firstname instead of customer_name. Becuase customer_name not match with any table
    – Camit1dk
    Jul 21 '17 at 13:33
  • You have any patch available for this issue? Jul 21 '17 at 13:38
  • Check my comment in below link, Its solved github.com/magento/magento2/issues/10301
    – Camit1dk
    Jul 22 '17 at 5:30

Here is the solution...

Create new module


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="2.1.0">
            <module name="Magento_Review"/>


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Reports\Block\Adminhtml\Review\Customer" type="Vendor\Module\Block\Adminhtml\Review\Customer" />
    <preference for="Magento\Reports\Model\ResourceModel\Review\Customer\Collection" type="Vendor\Module\Model\ResourceModel\Review\Customer\Collection" />



namespace Vendor\Module\Block\Adminhtml\Review;

class Customer extends \Magento\Reports\Block\Adminhtml\Review\Customer
    protected function _prepareLayout()

        $customerNameColumn = $this->getChildBlock('grid')

        return $this;


namespace Vendor\Module\Model\ResourceModel\Review\Customer;

class Collection extends \Magento\Reports\Model\ResourceModel\Review\Customer\Collection
    public function addFieldToFilter($field, $condition = null)
        if (is_array($field) && array_key_exists('like', $condition)) {
            $condition = array_fill(0, count($field), $condition);

        return parent::addFieldToFilter($field, $condition);
  • Good answer :) +1 for you. Also if I not found any answer within 6 days I will give +50 boundary. Yes I know we can override core file and solve this problem. But I don't need external module for it, I need patch for pull code on magento 2 github. If you found any patch for it. you can also pull code on magento 2 github repository. Jul 24 '17 at 6:12
  • you can create your own patch based on this module, but I don't like that way. you change core code. Jul 24 '17 at 8:12
  • Yes, you are right we should not change core but this is to help for Magento to implement this issue in next version. Anyway, I will try to create a patch for it. Jul 24 '17 at 8:51
  • @PrincePatel's idea is the way to go: provide a patch for this bug in order to let it get merged into the core -> you should try to get on GitHub and add one.
    – Max
    Jul 25 '17 at 19:23

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.