View Single Post
  #6  
Old 08-12-2019, 12:15 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: How to show all products related to an entity in another model

I don't really know what you are doing or how or what your full module looks like. So the code is intended to give you a hint and not to be used directly. You probably have to modify it to fit your module.

For example I keep saying "books" as you call them that but then in your code you use "products" - so obviously you have to modify this snippet of code to fit your module and needs.

The "find" method on the entity will search by the table primary id field (whatever that is) so there is no need to use "findby".

If the $products variable after you do the "find" gives you all the products as expected then the following errors are somewhere else in your code. However - you are trying to change what getData returns and this may also change the type of data being returned. So this could be the reason you are seeing the error.

Best is to modify the $cnd variable and then call the parent getData with the new conditions.

These are just fragments of code you are posting so it is really hard to give you exact code. But it does sound like if you apply author condition to it will give you what you need. So you may just need to add this to the $cnd variable in getData. Again - you will need to know what is already there, what exactly you are passing, etc.
If your author field in the products table is not author but authors (since you have Many To Many relationship you may need to pass a collection of authors even if it is just one.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote