VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: Geppux on February 15, 2018, 13:05:39 PM

Title: Error after deleting variant in multi-variant custom field
Post by: Geppux on February 15, 2018, 13:05:39 PM
J 3.8.5 - VM 3.2.12
Hi,
I was creating variants in a parent product and I wanted to change the order of the variants  (there are 3 variants); I deleted the second variant because I wanted to be the third and I saved.  From this point I can not open anymore the parent product, I receive the following error:  Cannot use object of type stdClass as array
Any suggestion? thank you
Giuseppe
Title: Re: Error after deleting variant in multi-variant custom field
Post by: Geppux on February 16, 2018, 16:00:53 PM
I solved taking all the description data from the DB deleting the faulty product and creating a new one, but I would like to know what happened just not to repeat it, thank you.
Giuseppe.
Title: Re: Error after deleting variant in multi-variant custom field
Post by: lica on March 05, 2018, 15:11:03 PM
This happens because after a deletion of a ramification the options associated to the child products are saved as an object instead of a normal array. Then in visualization this is not considered. I fixed modifying line 285 of file models/customfields.php from:

if(!isset($myoption[$k])){

to

if (is_object($myoption) && property_exists($myoption, $k)) {
                                    $value = $myoption->$k;
                                } else if(!isset($myoption[$k])){

is not the best fix, would be better to fix the save when a ramification is deleted. On top of that any update of VM will rewrite the file and you will lose the modification.

Hope they will release an update with a definitive fix to this issue
Title: Re: Error after deleting variant in multi-variant custom field
Post by: lica on August 23, 2018, 15:49:59 PM
Same topic also here: https://forum.virtuemart.net/index.php?topic=136939.0
Title: Re: Error after deleting variant in multi-variant custom field
Post by: Studio 42 on August 23, 2018, 23:18:57 PM
Yes, multi variant have know bugs. I dont checked because i find it too complex and use other solutions.