News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Division by Zero on com_virtuemart/models/product.php [SOLVED]

Started by inopia, July 02, 2012, 13:42:56 PM

Previous topic - Next topic

inopia

Hi dudes,

I´ve recently upgrade tu 2.0.8a version. Aparently everything runs ok but system show this warning:

Warning: Division by zero in */administrator/components/com_virtuemart/models/product.php on line 516

How can i do to fix this? It´s a bug from last version 2.0.8a?

Thank you.

inopia

I´ve observed if select 6 items per page or more this warning dissapears and when i select again 3 items per page all works but if you reloads the site with clean cache this issue appears again.

The warning appears when this line are evaluated:

$rest = $suglimit%$category->products_per_row;

I think $suglimit gets my item limit per row from my VirtueMart settings (10). by the way a division by zero isn´t possible but...

Suggestions?

Thxu


bytelord

Have the same issue with v2.0.8a.

As i see the $category->products_per_row does not return the products per row, but zero, for that reason that error appears.

Its a bug i suppose that need to get fixed.

Nikos
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

bytelord

i find out what have been changed.

the $category->products_per_row is coming from the category configuration on the backend. So by default that value is '0'.
That means that category oprions from shop->configuration are overided from category products_per_row.

If you go to each category and place there an option for products per row then the error is resolved.
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

inopia

bytelord, you´re right!

I´ve solved it like you said. I´m a beginner on VM and i don´t think could be this possibility.

If you need something i will try to help you.

Thank you very much.

bytelord

You are welcome. Its a bug as i have seen until now, except if there is something wrong with the upgrade from 2.06 to 2.0.8a.

Until now what i have seen is that the "Default number of products in a row" under Configuration->Templates->Shopfront settings is been overrided from the category configuration.
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

inopia


vynette

Thank you so much Bytelord. I have only just started building my site a few days ago for the first time. I thought I did something wrong. I have changed my 42 categories now and all is good thank you. When they upgrade again next time do they fix that ? And then will the configuration/template numbers over ride those ones I just changed  if I want to change them or will I have to go back  in and change all of them all again ? thank you for your help.

inopia

Seriously.

Probably we must set up all the fields correctly and probably the devs must handle default field values when users generated categories, yet users have to know that zero elements in a row have no sense.

esanchez1091

Thanks bytelord that was the fix.....


bytelord

    Beginner
    *
    Posts: 6
        View Profile
        Personal Message (Online)

Re: Division by Zero on com_virtuemart/models/product.php
« Reply #3 on: Today at 06:41:54 »

    Quote

i find out what have been changed.

the $category->products_per_row is coming from the category configuration on the backend. So by default that value is '0'.
That means that category oprions from shop->configuration are overided from category products_per_row.

If you go to each category and place there an option for products per row then the error is resolved.


[attachment cleanup by admin]

Milbo

It should be even enough to write this into the vm config. But I checked the code again and found that I am not checking for this, please use this code

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;

}

Then it should work always and use the standard value.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

bytelord

Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!


cecilia2330

Quote from: Milbo on July 02, 2012, 22:47:18 PM
It should be even enough to write this into the vm config. But I checked the code again and found that I am not checking for this, please use this code

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;

}

Then it should work always and use the standard value.

Sorry that, anyone know where to find the vm config. ??
I want to try Milbo 's solution

Loris

Quote from: cecilia2330 on July 03, 2012, 18:47:49 PM
Quote from: Milbo on July 02, 2012, 22:47:18 PM
It should be even enough to write this into the vm config. But I checked the code again and found that I am not checking for this, please use this code

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;

}

Then it should work always and use the standard value.

Sorry that, anyone know where to find the vm config. ??
I want to try Milbo 's solution

in /administrator/components/com_virtuemart/models/product.php

replace the original 2.0.8a code 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;
}
}

$rest = $suglimit%$category->products_per_row;
$limit = $suglimit - $rest;

}


with the Milbo's code