News:

Support the VirtueMart project and become a member

Main Menu

How to create a page with all products sorted by create date?

Started by borro, December 03, 2015, 15:09:43 PM

Previous topic - Next topic

borro

Hello!

How to create a page with ALL products from ALL categories which sorted by descending product created_on date?

VM 3.0.9
Wish you happiness!

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

borro

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?
Wish you happiness!

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

borro

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?
Wish you happiness!

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation