VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: baoquocmt159 on June 05, 2015, 11:26:44 AM

Title: How to get full list products
Post by: baoquocmt159 on June 05, 2015, 11:26:44 AM
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 !
Title: Re: How to get full list products
Post by: jenkinhill on June 05, 2015, 13:11:21 PM
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.
Title: Re: How to get full list products
Post by: baoquocmt159 on June 05, 2015, 16:47:07 PM
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 !
Title: Re: How to get full list products
Post by: baoquocmt159 on June 06, 2015, 08:34:53 AM
Some one help me?  :(
Title: Re: How to get full list products
Post by: jenkinhill on June 06, 2015, 14:31:39 PM
See http://forum.virtuemart.net/index.php?topic=104795.0
Title: Re: How to get full list products
Post by: baoquocmt159 on June 07, 2015, 15:37:20 PM
Hi all,

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

Thanks
Title: Re: How to get full list products
Post by: GJC Web Design on June 08, 2015, 00:41:04 AM
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];
      }
Title: Re: How to get full list products
Post by: JLinker on April 01, 2016, 18:09:51 PM
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
Title: Re: How to get full list products
Post by: GJC Web Design on April 02, 2016, 00:13:21 AM
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
Title: Re: How to get full list products
Post by: 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  ?
Title: Re: How to get full list products
Post by: baoquocmt159 on April 03, 2016, 16:18:56 PM
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
Title: Re: How to get full list products
Post by: JLinker on April 06, 2016, 11:14:55 AM
Hello, could we please know how this has been solved?
Title: Re: How to get full list products
Post by: JLinker on April 06, 2016, 12:10:31 PM
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?
Title: Re: How to get full list products
Post by: Studio 42 on April 06, 2016, 13:54:46 PM
Check some articles about it.
Eg. http://www.elated.com/articles/object-oriented-php-working-with-inheritance/