VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: amorino on July 08, 2019, 07:32:16 AM

Title: Latest Products and Recently Viewed Products in cat page
Post by: amorino on July 08, 2019, 07:32:16 AM
Hello,

I need to get Latest Products and Recently Viewed Products after Products in the category page
I searched since many days but I didn't find where to set that or where to change files

Joomla! 3.9.8
Virtuemart 3.4.2

I hope really getting some help on this matter
Best regards
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: jjk on July 15, 2019, 17:30:53 PM
Create a new 'VirtueMart Products' module, configure it's settings, assign only the category you want to attach it to in the 'Menu Assignment' tab and publish it in a template position below the main content area.
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: amorino on July 21, 2019, 06:30:05 AM
Hello,
Thank you
@jjk I found a real difficulties with the design of my template
So the best thing for me would to revert them in the category template
Any help please ?

Thank you
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: jjk on July 21, 2019, 12:01:13 PM
Quote from: amorino on July 21, 2019, 06:30:05 AM
@jjk I found a real difficulties with the design of my template

Which template? And what is the problem with the template?
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: Studio 42 on July 22, 2019, 11:30:06 AM
Do an override from file JOOMLAROOT/components/com_virtuemart/views/category/tmpl/default.php
   echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
is the code to render all the products
If you want to render it in another order, the only solution is to invert/manipulate the array : $this->products.
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: amorino on July 25, 2019, 10:10:54 AM
Hello,
Thank you @Studio 42

Yes that's it I just want to invert that array
How to do it please ?
How that code should be to invert ?
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: Studio 42 on July 25, 2019, 12:03:39 PM
https://www.php.net/manual/en/function.array-reverse.php (https://www.php.net/manual/en/function.array-reverse.php)
$products= array_reverse($this->products, true);
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: amorino on July 26, 2019, 07:42:42 AM
Hello Studio 42
This didn't work for me

But I made an other try that worked fine :

echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));

I think that this should be rendered in some template as now I want to revert new products and last seen on the same page  hhhhhh
Any idea which code is rendering this
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: Studio 42 on July 26, 2019, 12:13:39 PM
have you add the line in the right file
$products= array_reverse($this->products, true);
and change
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));a layout
with
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
If yes, then my code should work.
I cannot help you, if you dont know how to do overrides in the template
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: amorino on July 26, 2019, 16:39:55 PM
Hello,
Thank you a lot
I did overrides in the template with no problem

I found the solution and worked well in my previous message

But now I want to change order of blocks new products and last seen on the same cat page
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: Studio 42 on July 26, 2019, 23:43:07 PM
 if you want to customise the order then you have to manipulate the array $this->products directly or do a new array and add the products list(new, last ...) as you want.
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: amorino on July 29, 2019, 15:53:42 PM
Hello Studio 42
Thanks
Any example of code please ?
Thanks
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: Studio 42 on July 29, 2019, 16:03:19 PM

$lists = array();
$lists['related'] = $this->products['related'];
$lists['featured'] = $this->products['featured'];
$lists[0] = $this->products[0];
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$lists,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating);
Title: Re: Latest Products and Recently Viewed Products in cat page
Post by: Studio 42 on July 29, 2019, 16:06:37 PM
note that i replaced $this->products by $lists in
shopFunctionsF .... array('products'=>$lists

If you dont understand, then please hire someone to do it, it's really a basic PHP code