VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Naveen Kumar on March 17, 2017, 21:27:14 PM

Title: Product update error!
Post by: Naveen Kumar on March 17, 2017, 21:27:14 PM
Hello, everyone, I got stuck with something that I have never experienced before. Okay, problem is that when I try to select multivariant for the products and hit save it works wonderfully well and the value I am trying to save is updated. But when I try to update the same product second time around I came up with the following errors below:

On the backend I see:
Fatal error: Cannot use object of type stdClass as array in /home/XXXXXXXXXX/XXXXXXXXX/administrator/components/com_virtuemart/models/customfields.php on line 312

Front end:
Fatal error: Cannot use object of type stdClass as array in /home/XXXXXX/XXXXXX/templates/fire/html/com_virtuemart/sublayouts/customfield.php on line 114


Thank You.
Title: Re: Product update error!
Post by: GJC Web Design on March 17, 2017, 22:15:54 PM
versions??

http://forum.virtuemart.net/index.php?topic=79799.0
Title: Re: Product update error!
Post by: Naveen Kumar on March 17, 2017, 23:24:59 PM
My bad!

I should have mentioned it in the first place.

VM 3.0.18
Joomla 3.6.5

Thanks
Title: Re: Product update error!
Post by: Naveen Kumar on March 21, 2017, 17:28:23 PM
Hello any update here?

In addition to my previous post "I am not able get the values of my own custom field created in cart." Error I get "com_virtuemart/sublayouts/customfield.php  ------------- line no --------736"

Here is code below if we comment this line of code it is working fine but not able to populate/show custom  field value in cart list.

/* if(!empty($productCustom->selectoptions[$k]->clabel) and in_array($productCustom->selectoptions[$k]->voption,VirtueMartModelCustomfields::$dimensions)){
                                    $value .= vmText::_('COM_VIRTUEMART_'.$productCustom->selectoptions[$k]->voption);
                                    $rd = $productCustom->selectoptions[$k]->clabel;
                                    if(is_numeric($rd) and is_numeric($option)){
                                        $value .= ' '.number_format(round((float)$option,(int)$rd),$rd);
                                    }
                                } else {
                                    if(!empty($productCustom->selectoptions[$k]->clabel)) $value .= vmText::_($productCustom->selectoptions[$k]->clabel);
                                    $value .= ' '.vmText::_($option).' ';
                                } */



Thanks
Title: Re: Product update error!
Post by: GJC Web Design on March 21, 2017, 17:42:36 PM
Try VM3.2 - downloads
Title: Re: Product update error!
Post by: Naveen Kumar on March 24, 2017, 18:04:38 PM
Hello,

Thanks for the response.

But it didn't work.

Any suggestions please ?
Title: Re: Product update error!
Post by: lica on August 23, 2018, 15:39:48 PM
Hi,
the problem is that when you change the ramifications of the multivariat associated to a product the link between the child products and the corresponding variants is transformed from a simple array to an associative one, since you may remove the second ramification out of three and you need the kay to keep the correct correspondence between the actual left ramifications and the values for each child. At db these is translated to a json object. When data is again retrieved the json object is parsed to a php stdClass object instead that an associative array.

Since in all the code the result is treated as an array when it gets an object it raises a fatal error.

Theoretically if json_decode is used to parse the data from db it would be sufficient to pass as second parameter TRUE in order to get as result an associative array and not a stdClass object: http://php.net/manual/en/function.json-decode.php

Unfortunately I wasn't able to identify the exact point where to fix this, for know I just fix this by transforming the stdClass object into an associative array when I get the error.

I've just checked VM 3.2.14.9808 and the bug persists, hope will be fixed in next release.
Title: Re: Product update error!
Post by: lica on August 23, 2018, 15:49:06 PM
Same topic also here: https://forum.virtuemart.net/index.php?topic=139547.msg490287#msg490287