News:

Looking for documentation? Take a look on our wiki

Main Menu

Error when saving product VM 3.0.2 -Joomla 3.3.6

Started by BrownSystems, December 19, 2014, 17:11:32 PM

Previous topic - Next topic

BrownSystems

Just setup a fresh install of VM and Joomla. Went to add a product and I get:

"PHP Warning:  implode(): Invalid arguments passed in administrator\components\com_virtuemart\models\product.php on line 938"

Am I the only one with this?

BrownSystems

#1
Mostly fixed the problem.

In "\administrator\components\com_virtuemart\models\product.php" on line 938 I changed:


$hash = $productId.','.implode($virtuemart_shoppergroup_ids,'.').','.(int)$front; //md5($q);

To:

$hash=$productId.',';
    if(is_array($virtuemart_shoppergroup_ids)){
     $hash.=implode($virtuemart_shoppergroup_ids,'.'); //md5($q);
    }else{
     $hash.=$virtuemart_shoppergroup_ids; //md5($q);
    }
    $hash.=','.(int)$front;


This prevents the implode function from throwing a warning when only "0"is passed in the variable "$virtuemart_shoppergroup_ids". This occurs when the store() function makes this call

$old_price_ids = $this->loadProductPrices($this->_id,0,false); on line 1690 where the second parameter is zero when implode expects an array.

Then in loadProductPrices() (now line 957)I changed this:

$loadedProductPrices[$hash] = false;

To this:

$loadedProductPrices = array();

Because in store() at line 1768 this:

if ( count($old_price_ids) )

needs to evaluate to zero or false and it does not since the array is set to array($hash => false) so it instead evaluates to "1".



Now I can save the product but the first time I enter prices and try to save I now get this error:

"Invalid argument supplied for foreach() in \administrator\components\com_virtuemart\models\product.php on line 1753"

The prices do save and after the initial save the error no longer occurs.

That's all the time I have to waste today. I'll be debuging more later but hopefully someone else can chime in. This is looking to be a painful transition from VM2 to VM3.

jenkinhill

The devs are fixing PHP warnings & notices as they work through the next few releases, and have added an option to turn off the display in Configuration/Shop/Advanced Settings
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

BrownSystems

Quote from: jenkinhill on December 19, 2014, 18:23:18 PM
The devs are fixing PHP warnings & notices as they work through the next few releases, and have added an option to turn off the display in Configuration/Shop/Advanced Settings

Thanks for the info. Just tested the config setting set to "No debug". I also have Error Reporting "none" in Joomla global config. Still get the warnings though. I'm on IIS7 so this is likely the reason as most will be on Apache.

Still though, seems like a pretty crucial warning. If you can't even create a product out of the box without changing configuration settings that would seem to be discouraging to a novice.

jenkinhill

PHP warnings & notices are rarely "crucial" but often indicate that a function is now depracated and may no longer work in furure PHP versions. See http://forum.virtuemart.net/index.php?topic=102555.0
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

BrownSystems

Quote from: jenkinhill on December 19, 2014, 19:03:04 PM
PHP warnings & notices are rarely "crucial" but often indicate that a function is now depracated and may no longer work in furure PHP versions. See http://forum.virtuemart.net/index.php?topic=102555.0


Thank you for the information. Yes I understand PHP Warnings and Notices. My point though is that if you can't even create a product out of the box then new VM users (especially a tech novice) will get discouraged and look for an e-commerce solution elsewhere. In my opinion that seems crucial.