VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: mhs_pro on December 15, 2018, 14:00:37 PM

Title: Get a certain number of products in per request
Post by: mhs_pro on December 15, 2018, 14:00:37 PM
Hi
I want to write an API to get the products and use product model in admin/component/com_virtuemart/models/product.php. There are some functions to get the products, like(getProductsInCategory, getProducts & getProductsListing)

$productModel = VmModel::getModel('Product');
$products = $productModel->getProductsInCategory($catId);

When I execute the above code return all products. I need to receive limited number of products in per request (ex. limit 20,10 in DB query) same as pagination in product listing page.
which function can I use for this purpose?
Title: Re: Get a certain number of products in per request
Post by: GJC Web Design on December 15, 2018, 14:21:00 PM
         $productModel = VmModel::getModel('Product');
         $products = $productModel->getProductListing($group, $nbrReturnProducts, $withCalc, $onlyPublished, $single, $filterCategory, $category_id, $filterManufacturer, $manufacturer_id);
Title: Re: Get a certain number of products in per request
Post by: mhs_pro on December 15, 2018, 14:38:35 PM
getProductListing function just return max number ($nbrReturnProducts) of products

ex.
there are 100 produts in #__virtuemart_products .
I need 20 products from id 60 to 80

$productModel = VmModel::getModel('Product');
$nbrReturnProducts = 20;
$products = $productModel->getProductListing($group, $nbrReturnProducts, $withCalc, $onlyPublished, $single, $filterCategory, $category_id, $filterManufacturer, $manufacturer_id);

but this code returns products from id 1 to 20.
Title: Re: Get a certain number of products in per request
Post by: GJC Web Design on December 15, 2018, 15:05:48 PM
then u will need to overload the function or write your own - pagination is interactive - you need to know what you already displayed/accessed