Hello,
I am developing an eshop with food and the clients needs to have the following view:
In the main category view, he wnats to view all the products separated in subcategories and if a product has two categories, it should be displayed twice. You can see what I mean in the screenshot I have attached.
The category tree is Deli (main category) -> Salt, Pasta, Bread etc.
The products have subcategories but not the main category.
I am displaying all the products in the category Deli menu item which is set to display the products from the subcategories.
So, the structure I want to have in the Deli page is:
Deli
->Subcategory 1 (name and description)
->Product
->Product
->Product
->Subcategory 2 (name and description)
->Product
->Product
->Product
I have tried calling the products sublayout inside the categories foreach in the file sublayouts/categorires.php:
On around line 48 foreach ( $categories as $category ) {...}
I have added the following:
if (!empty($this->products)) {
if($this->fallback){
$p = $this->products;
$this->products = array();
$this->products[0] = $p;
vmdebug('Refallback');
}
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
}
With this code I get a
0 - Using $this when not in object context error. I tried changing $this to $category or $product but nothing happens.
So, what I want to do is:
- Display all the products of the main category, separated in subvcategories
- A product that is is two categories, should be displayed twice - once for each category
Joomla Joomla! 3.9.25
Virtuemart 3.8.4
Php 7.3
Any help would be much appreciated.