VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: sandomatyas on December 10, 2018, 11:10:30 AM

Title: Custom product query + category layout
Post by: sandomatyas on December 10, 2018, 11:10:30 AM
I want to create a custom product list with my special requests (like products in stock and added in the last week and cheaper than a limit and not featured and have a specific custom field value, etc). The query is okay, I can fetch the records from the database.
But what do you suggest to display them like VM displays products of a category? Basically I need using the products sublayout and a proper pagination. Building a custom component with an own pagination and use VM sublayouts?
Or any better idea?
Title: Re: Custom product query + category layout
Post by: StefanSTS on December 10, 2018, 12:21:40 PM
As much as possible I would try to operate with categories.

Depend if you can set a category for these products you could just create a "below this price"-category and so on and use a custom products.php like products_belowprice.php.

If that does not work, the new products_something.php could also hold higher level categories and you filter in the loop for the prices you need.

Stefan
Title: Re: Custom product query + category layout
Post by: GJC Web Design on December 10, 2018, 14:52:14 PM
use a custom products.php

agree with stefan - it is very easy actually to create a complete "other" VM "view"  by just duplicating and renaming the model, view folder  etc etc and then as suggested adapt the products_myname.php to what u need

have also done different views by duplicating the products.php model, renaming and the class and calling it in your view by

$productModel = VmModel::getModel('Productmy');

then use all the normal functions
Title: Re: Custom product query + category layout
Post by: sandomatyas on December 10, 2018, 15:26:08 PM
Nice one thanks. My only fear that with this idea I miss a lot of new features and bugfixes mostly in the model. Maybe extend the new model from the old one and override only a few methods could help to maintain the code integrity when I update VirtueMart
Title: Re: Custom product query + category layout
Post by: Studio 42 on December 10, 2018, 22:28:45 PM
Of course use product model as parent if you use most same function or vmmodel if not.