VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: johnyDev on February 15, 2014, 18:00:59 PM

Title: Pagination system with getProductListing function in my module
Post by: johnyDev on February 15, 2014, 18:00:59 PM
Hello,

I just want to use the function "getProductListing" in my module but with pagination system, I want it to accept $perPage paramater and $start paramater

1/ Can I use the existent funtion with pagination system (it will be great)
2/ Is there any solution, I can for example copy paste the code in my module and then modify it, but how can I modify it ?

Thank you.     


getProductListing    (         $group = FALSE,
           $nbrReturnProducts = FALSE,
           $withCalc = TRUE,
           $onlyPublished = TRUE,
           $single = FALSE,
           $filterCategory = TRUE,
           $category_id = 0
   )       
Title: Re: Pagination system with getProductListing function in my module
Post by: Milbo on February 15, 2014, 21:19:59 PM
yes you can use it. The function works with pagination. Please read here http://dev.virtuemart.net/projects/virtuemart/wiki/Developing_a_module_or_plugin_for_VirtueMart_2

you need 3 lines.
Title: Re: Pagination system with getProductListing function in my module
Post by: Milbo on February 15, 2014, 21:25:21 PM

if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');
VmConfig::loadConfig();

$pmodel = VmModel::getModel('product');
$myproducts = $pmodel -> getProductListing(....);
Title: Re: Pagination system with getProductListing function in my module
Post by: johnyDev on February 16, 2014, 00:58:19 AM
Thank you for your answer, but I know how to use that function, but didn't find a way to manage the pagination with that function, to pass $start and $limit parameters, actually what I did is copy and paste the function and change it to accept two more parameters ... it's not the best implementation but it works... now I have another problem it will be great you take a look  : https://forum.virtuemart.net/index.php?topic=122261.msg417236
Title: Re: Pagination system with getProductListing function in my module
Post by: Milbo on February 16, 2014, 18:43:03 PM
You must set the Pagination via Post or userstate stuff.