VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: z-analysts on July 02, 2012, 16:56:29 PM

Title: [SOLVED] WARNING: Division by zero error message
Post by: z-analysts on July 02, 2012, 16:56:29 PM
Warning: Division by zero in /home/XXXXXXXX/public_html/XXXXXXXX/administrator/components/com_virtuemart/models/product.php on line 516

I just upgraded to 2.0.8a and got the above PHP warning message when I display products in category view.

Title: Re: WARNING: Division by zero error message
Post by: strophe on July 02, 2012, 17:18:45 PM
Hi everyone.

Same error, same place, same update...
Title: Re: WARNING: Division by zero error message
Post by: andrew.glover on July 02, 2012, 17:26:09 PM
Hi all,
As with the others above. Same bug, same place, same upgrade.
Title: Re: WARNING: Division by zero error message
Post by: sakabra on July 02, 2012, 17:27:56 PM
Me too!  :(
Title: Re: WARNING: Division by zero error message
Post by: JerryQ on July 02, 2012, 17:32:08 PM
try this:
replace line 516 with this:
    if($category->products_per_row>0){
   $rest = $suglimit%$category->products_per_row;
    }else{
   $rest =1;}
Title: Re: WARNING: Division by zero error message
Post by: andrew.glover on July 02, 2012, 17:33:28 PM
Hi all,
Although I haven't explored all the repercussions to doing so. I solved the problem by simply commenting out line 516. It seams to work without affecting any other part of the shop.
Title: Re: WARNING: Division by zero error message
Post by: z-analysts on July 02, 2012, 17:41:32 PM
This is a better solution: http://forum.virtuemart.net/index.php?topic=104707.0.
Title: Re: [SOLVED] WARNING: Division by zero error message
Post by: Milbo on July 02, 2012, 21:55:00 PM
The best solution is imho the one above and this

if(empty($limit)){
if(!empty($category->limit_list_initial)){
$suglimit = $category->limit_list_initial;
} else {
if(empty($category->limit_list_step)){
$suglimit = VmConfig::get ('list_limit', 20);
} else {
$suglimit = $category->limit_list_step;
}
}
if(empty($category->products_per_row)){
$category->products_per_row = VmConfig::get ('products_per_row', 3);
}
$rest = $suglimit%$category->products_per_row;
$limit = $suglimit - $rest;

}