File tree Expand file tree Collapse file tree 2 files changed +37
-6
lines changed
Expand file tree Collapse file tree 2 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -877,15 +877,17 @@ public function getAttributes($groupId = null, $skipSuper = false)
877877 */
878878 public function beforeSave ()
879879 {
880- $ this ->setTypeHasOptions (false );
881- $ this ->setTypeHasRequiredOptions (false );
882- $ this ->setHasOptions (false );
883- $ this ->setRequiredOptions (false );
880+ if ($ this ->getData ('has_options ' ) === null ) {
881+ $ this ->setHasOptions (false );
882+ }
883+ if ($ this ->getData ('required_options ' ) === null ) {
884+ $ this ->setRequiredOptions (false );
885+ }
884886
885887 $ this ->getTypeInstance ()->beforeSave ($ this );
886888
887- $ hasOptions = false ;
888- $ hasRequiredOptions = false ;
889+ $ hasOptions = $ this -> getData ( ' has_options ' ) === " 1 " ;
890+ $ hasRequiredOptions = $ this -> getData ( ' required_options ' ) === " 1 " ;
889891
890892 /**
891893 * $this->_canAffectOptions - set by type instance only
Original file line number Diff line number Diff line change @@ -1095,6 +1095,35 @@ public function testSaveAndDuplicate()
10951095 $ this ->model ->afterSave ();
10961096 }
10971097
1098+ /**
1099+ * Test for save method behavior with type options
1100+ */
1101+ public function testSaveWithoutTypeOptions ()
1102+ {
1103+ $ this ->model ->setCanSaveCustomOptions (false );
1104+ $ this ->model ->setTypeHasOptions (true );
1105+ $ this ->model ->setTypeHasRequiredOptions (true );
1106+ $ this ->configureSaveTest ();
1107+ $ this ->model ->beforeSave ();
1108+ $ this ->model ->afterSave ();
1109+ $ this ->assertTrue ($ this ->model ->getTypeHasOptions ());
1110+ $ this ->assertTrue ($ this ->model ->getTypeHasRequiredOptions ());
1111+ }
1112+
1113+ /**
1114+ * Test for save method with provided options data
1115+ */
1116+ public function testSaveWithProvidedRequiredOptions ()
1117+ {
1118+ $ this ->model ->setData ("has_options " , "1 " );
1119+ $ this ->model ->setData ("required_options " , "1 " );
1120+ $ this ->configureSaveTest ();
1121+ $ this ->model ->beforeSave ();
1122+ $ this ->model ->afterSave ();
1123+ $ this ->assertTrue ($ this ->model ->getHasOptions ());
1124+ $ this ->assertTrue ($ this ->model ->getRequiredOptions ());
1125+ }
1126+
10981127 public function testGetIsSalableSimple ()
10991128 {
11001129 $ typeInstanceMock =
You can’t perform that action at this time.
0 commit comments