Hello!
How to create a page with ALL products from ALL categories which sorted by descending product created_on date?
VM 3.0.9
with &orderby=created_on and &virtuemart_category_id in the url
then this to get all products of all cats to show
in models/product.php
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
if(true){
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
} else {
/*GJC add subcat products*/
$catmodel = VmModel::getModel ('category');
$childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
$cats = $virtuemart_category_id;
foreach($childcats as $childcat){
$cats .= ','.$childcat->virtuemart_category_id;
}
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
}
it is only in vm3.0.12
added query for loading products of subcategories, is atm without option and disabled with an if(true), option will come atm easier for updaters
guess you'll need if >= 0 for cat id
Quote from: GJC Web Design on December 04, 2015, 00:18:52 AM
with &orderby=created_on and &virtuemart_category_id in the url
then this to get all products of all cats to show
in models/product.php
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
if(true){
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
} else {
/*GJC add subcat products*/
$catmodel = VmModel::getModel ('category');
$childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
$cats = $virtuemart_category_id;
foreach($childcats as $childcat){
$cats .= ','.$childcat->virtuemart_category_id;
}
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
}
it is only in vm3.0.12
added query for loading products of subcategories, is atm without option and disabled with an if(true), option will come atm easier for updaters
guess you'll need if >= 0 for cat id
Hello!
Thank you for your suggestion.
I am little bit misunderstanding.
1.What url for that page should look like? like this
site.com/component=virtuemart&orderby=created_on&virtuemart_category_id=0
?
2. What should be instead of
Quoteif(true){
in the code?
if(false) ?
Quote from: GJC Web Design on December 07, 2015, 12:18:29 PM
if(false) ?
if there will be "if(true)" in the code the programm will never go to the
else {
/*GJC add subcat products*/
$catmodel = VmModel::getModel ('category');
$childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
$cats = $virtuemart_category_id;
foreach($childcats as $childcat){
$cats .= ','.$childcat->virtuemart_category_id;
}
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
}
branch of code.
so why do we need it?
And vise versa if there will be if(false){...
we don't need the branch
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
in the code
May be I don't understand you and I have to replace if(true) or if(false) with something else I don't understand, don't I?
Did I give the correct view of the url at my first question?
if u want to show all products from all cats incl. subcats you need to use the /*GJC add subcat products*/
code it what ever way you want
url is roughly correct .. but try it
turn off ALL sef while developing