Author Topic: Error after deleting variant in multi-variant custom field  (Read 279 times)

Geppux

  • Jr. Member
  • **
  • Posts: 173
Error after deleting variant in multi-variant custom field
« 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

Geppux

  • Jr. Member
  • **
  • Posts: 173
Re: Error after deleting variant in multi-variant custom field
« Reply #1 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.

lica

  • Beginner
  • *
  • Posts: 3
  • A beginner
Re: Error after deleting variant in multi-variant custom field
« Reply #2 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