Jump to content

CustomerQueryBuilder error

Recommended Posts


I don't know if this bug has still been reported. But I haven't found any topic about it.

This bug only appears if you create a module that modify the Customer Grid.

I've created a new table PS_relatives to establish links between customers. Each customer record may have a PS_relatives record which contains his customer id and the customer id of the relative named relative_id.

I have add on the Customer grid 2 columns : PS_relatives.Relative_Id  and "relative_name" which is a calculated field concatenating first name and lastname obtained by a left join on PS_Customer.

So far, so good, it's working. But if you try to search name in Lastname column (which is a standard column) you will get an error :


SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'lastname' in where clause is ambiguous.

The error come from src/Core/Grid/CustomerQueryBuilder.php in private function applyFilters, line 229. You will see on the line :

      $qb->andWhere('`' . $filterName . '` LIKE :' . $filterName);  that there is no prefix before $filterName, as ther is "c." for each particular field just above.

To correct the error just add c. like this : $qb->andWhere('c.`' . $filterName . '` LIKE :' . $filterName).

Hope it will help.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More