News:

Looking for documentation? Take a look on our wiki

Main Menu

Get a certain number of products in per request

Started by mhs_pro, December 15, 2018, 14:00:37 PM

Previous topic - Next topic

mhs_pro

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?

GJC Web Design

         $productModel = VmModel::getModel('Product');
         $products = $productModel->getProductListing($group, $nbrReturnProducts, $withCalc, $onlyPublished, $single, $filterCategory, $category_id, $filterManufacturer, $manufacturer_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

mhs_pro

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.

GJC Web Design

then u will need to overload the function or write your own - pagination is interactive - you need to know what you already displayed/accessed
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