View Single Post
  #4  
Old 08-12-2019, 05:24 AM
  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

getData() works off of the request so you need to look at what your request is and what getData() gives you.
Use the Doctrine dump to check the data if you are not sure. You should have Author if you want to get the books associated with the entity.
So you can do like

Code:
protected function getData(\XLite\Core\CommonCell $cnd, $countOnly = false) { $data = parent::getData($cnd, $countOnly); // check if $data has author id - it should have something to relate to what you are trying to get // then you can use it $author = Database::getRepo('\XLite\Model\Product')->find($data-authoutId); $books = $author->getProducts(); // of course make sure you have the id in the request and it is called authorId }

If you want to use
Code:
$this->getProducts()
you need to define getProducts() within this class - since you are getting error on that call it means it is not defined in the class or any of its parents
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote