Author Topic: Error after deleting variant in multi-variant custom field  (Read 632 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: 6
  • 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

lica

  • Beginner
  • *
  • Posts: 6
  • A beginner

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3388
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Error after deleting variant in multi-variant custom field
« Reply #4 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.