View Single Post
  #3  
Old 08-11-2019, 11:08 PM
 
Ed B. Ed B. is offline
 

X-Adept
  
Join Date: Apr 2016
Posts: 446
 

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

Quote:
Originally Posted by cflsystems
First of all why are you making Many To Many relationship? If you do this it means one book can be written by more than one author. I mean there are cases when a book has multiple co-writers but they are usually treated as team?
Some authors may write alone and collaborate with others, and for statistic
reasons (and others), we have made this choice.




Quote:


I would change that to One Book One Writer and One Writer Many Books relationship.

The you can easily get Author/Books by using Book->getAuthor() and Author->getBooks()

Even with Many To Many connection you still use Entity->getBooks() and Entity->getAuthors()

There is no need of any fancy functions.




Author->getBooks() is actually working (as long as I define the method for each widget class!), my problem is to use the output of this to "feed" getData(). For example, if I do
Code:
protected function getData(\XLite\Core\CommonCell $cnd, $countOnly = false) { $this->getProducts(); }
I get "call to undefined function", and if I do

Code:
protected function getData(\XLite\Core\CommonCell $cnd, $countOnly = false) { PathToMyViewerWidget::getProducts(); }
then I get "use of $this not in object context" error.
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote