Jump to content
Orthofoods

CustomerQueryBuilder error

Recommended Posts

Hello,

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

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