News:

Support the VirtueMart project and become a member

Main Menu

How to get full list products

Started by baoquocmt159, June 05, 2015, 11:26:44 AM

Previous topic - Next topic

baoquocmt159

Hi all,

I use Joomla 3.4 and VM 3.0.9 , I want get all products, i did used :

$model = VmModel::getModel('product');
$products = $model->getProductListing();


But it just get 24 product, please help me.

Thank you so much !

jenkinhill

VERSIONS?

As written many times, to display all in the FE you can just use use index.php?option=com_virtuemart&view=category&virtuemart_category_id=0  and make a template override if you want to change the layout of that page.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

baoquocmt159

Hi jenkinhill,

I used VM 3.0.9, i'm coding for plugin, not template, so i want get the all products to display.

Thank you !

baoquocmt159


jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

baoquocmt159

Hi all,

I think VM team and many people have the ability to help me. But they not have goodness.

Thanks

GJC Web Design

if u bothered to find and look at the function you would see->

public function getProductListing ($group = FALSE, $nbrReturnProducts = FALSE, $withCalc = TRUE, $onlyPublished = TRUE, $single = FALSE, $filterCategory = TRUE, $category_id = 0) {

later

if($nbrReturnProducts){
         $limitStart = 0;
         $limit = $nbrReturnProducts;
         $this->_withCount = false;
      } else if($this->_noLimit){
         $this->_withCount = false;
         $limitStart = 0;
         $limit = 0;
      } else {
         $limits = $this->setPaginationLimits();
         $limitStart = $limits[0];
         $limit = $limits[1];
      }
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

JLinker

Hi I confirm the problem. I'm also calling the function this way:

$products = $productModel->getProductListing($group = FALSE, $nbrReturnProducts = FALSE, $withCalc = TRUE, $onlyPublished = TRUE, $single = FALSE, $filterCategory = FALSE, $category_id = 0);

I get exactly 24 products. If I set $nbrReturnProducts to 1000, I get 59 products.

Could we please have more information on how to get ALL products with this function?
Thanks a lot
JLinker - Mass Menu Link Generator for Joomla 2.5 and Joomla 3.x.
Generate hundreds of menu links in a few seconds for Joomla, K2, Community Builder, Phoca Download, JDownloads, SobiPro, Virtuemart. Website: http://www.jlinker.com

GJC Web Design

if you have no number set it returns what you have set in the admin pagination limits

$limits = $this->setPaginationLimits();

I have no idea why 1000 gives you 59 .. you need to follow thru the function to see why
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

Studio 42

You can inherit from the product Class.
If you have to many problem to use exactly original, then Do your custom Model to get products and override What you need .
baoquocmt159, I think you are a developper, is this so complex to do  ?

baoquocmt159

Quote from: Studio 42 on April 02, 2016, 00:58:58 AM
You can inherit from the product Class.
If you have to many problem to use exactly original, then Do your custom Model to get products and override What you need .
baoquocmt159, I think you are a developper, is this so complex to do  ?

Hi,

I have solved it :)

Thanks

JLinker

Hello, could we please know how this has been solved?
JLinker - Mass Menu Link Generator for Joomla 2.5 and Joomla 3.x.
Generate hundreds of menu links in a few seconds for Joomla, K2, Community Builder, Phoca Download, JDownloads, SobiPro, Virtuemart. Website: http://www.jlinker.com

JLinker

by the way, the example i've posted above uses the inherited category model. Whatever I do with the function, I get about 40% to 60% of the products. Here is my code again, there is nothing else:


$this->productModel = VmModel::getModel('Product');
$products = $this->productModel->getProductListing($group = FALSE, $nbrReturnProducts = 5000, $withCalc = TRUE, $onlyPublished = TRUE, $single = FALSE, $filterCategory = 0, $category_id = NULL);


This gives me 24 products on 86 in the first shop, 701 products on 1738 in the second shop.
Is it maybe because of a pagination system? How are we supposed to set the limits in an inherited custom model?
JLinker - Mass Menu Link Generator for Joomla 2.5 and Joomla 3.x.
Generate hundreds of menu links in a few seconds for Joomla, K2, Community Builder, Phoca Download, JDownloads, SobiPro, Virtuemart. Website: http://www.jlinker.com