2.0.24c and probably before
in file administrator/components/com_virtuemart/models/product.php it fires the getProducts() function line 1348
Code: [Select]
public function getProducts ($productIds, $front = TRUE, $withCalc = TRUE, $onlyPublished = TRUE, $single = FALSE) {
if (empty($productIds)) {
// vmdebug('getProducts has no $productIds','No ids given to get products');
// vmTrace('getProducts has no $productIds');
return array();
}
$maxNumber = VmConfig::get ('absMaxProducts', 700);
$products = array();
if ($single) {
foreach ($productIds as $id) {
$i = 0;
if ($product = $this->getProductSingle ((int)$id, $front)) {
$products[] = $product;
$i++;
}
if ($i > $maxNumber) {
vmdebug ('Better not to display more than ' . $maxNumber . ' products');
return $products;
}
}
}
else {
$i = 0;
foreach ($productIds as $id) {
if ($product = $this->getProduct ((int)$id, $front, $withCalc, $onlyPublished)) {
$products[] = $product;
$i++;
}
if ($i > $maxNumber) {
vmdebug ('Better not to display more than ' . $maxNumber . ' products');
return $products;
}
}
}
return $products;
}
you can see a line
$maxNumber = VmConfig::get ('absMaxProducts', 700);
this can be set in config - (don't see it) but any way as a test set to 2
$maxNumber = VmConfig::get ('absMaxProducts', 2);
no effect - all products returned
this part of the code is wrong
Code: [Select]
if ($single) {
foreach ($productIds as $id) {
$i = 0;
if ($product = $this->getProductSingle ((int)$id, $front)) {
$products[] = $product;
$i++;
}
if ($i > $maxNumber) {
vmdebug ('Better not to display more than ' . $maxNumber . ' products');
return $products;
}
}
}
the $i=0; is inside the loop so is reset to 0 every loop
if I change the code to
Code: [Select]
if ($single) {
$i = 0;
foreach ($productIds as $id) {
if ($product = $this->getProductSingle ((int)$id, $front)) {
$products[] = $product;
$i++;
}
print 'Debug Line '.__LINE__.' $i <pre>'; print_r ($i); print "</pre><br />\n";
if ($i > $maxNumber) {
vmdebug ('Better not to display more than ' . $maxNumber . ' products');
return $products;
}
}
}
then the code works as intended.. now it only returns 2 products (or what ever I set $maxNumber = VmConfig::get ('absMaxProducts', 700); to
Ehrm, thank you very much. little typo in the other if the $i is correct.
You can set values like this VmConfig::get ('absMaxProducts', 2); via the config fiel and the command "get values by file" in tools & migration
;)