Closed
Description
Certain permutations of product custom options are impossible to save. For example,
- First save a product with a custom option dropdown of two values with differing fields:
- Now try to save the second value to be identical to the first, like so:
- Notice that many of the values are not saved correctly. For me, this time around only the SKU was problematic, but you will have problems saving any number of these fields.
This is because
- the abstract resource model generates the
UPDATE
query based on differences between the new data array being saved and the preexisting$object->storedData
array. code reference - the OptionValue model loops through
setData
commands to save multiple OptionValue instances, hencestoredData
property refers to the previously saved Value instance, which is set during the previoussetData()->..->save() iteration
. code reference
So, those two reasons result in any identical OptionValue fields not able to be saved consecutively, causing the bug shown in steps 1-3.
I think it is rather odd/lazy that the option value model does not have its own resource model.. it seems like a poor idea to just loop through $this->setData()->save()
calls. But, if you want to fix this quickly, just issue a $this->load($this->getOptionTypeId())
before the save
. This will set the proper storedData
property onto the model.
Metadata
Metadata
Assignees
Labels
Distributed Contribution DayThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.3 release lineGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Failed. Automatic verification of issue format is failedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 release