File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -883,8 +883,8 @@ public function beforeSave()
883
883
884
884
$ this ->getTypeInstance ()->beforeSave ($ this );
885
885
886
- $ hasOptions = $ this ->getData ('has_options ' ) === "1 " ;
887
- $ hasRequiredOptions = $ this ->getData ('required_options ' ) === "1 " ;
886
+ $ hasOptions = $ this ->getData ('has_options ' ) === "1 " && $ this -> isProductHasOptions () ;
887
+ $ hasRequiredOptions = $ this ->getData ('required_options ' ) === "1 " && $ this -> isProductHasOptions () ;
888
888
889
889
/**
890
890
* $this->_canAffectOptions - set by type instance only
@@ -934,6 +934,21 @@ public function beforeSave()
934
934
parent ::beforeSave ();
935
935
}
936
936
937
+ /**
938
+ * Check based on options data
939
+ *
940
+ * @return bool
941
+ */
942
+ private function isProductHasOptions () : bool
943
+ {
944
+ if ($ this ->getData ('options ' ) === null ) {
945
+ $ result = true ;
946
+ } else {
947
+ $ result = is_array ($ this ->getData ('options ' )) && count ($ this ->getData ('options ' )) > 0 ;
948
+ }
949
+ return $ result ;
950
+ }
951
+
937
952
/**
938
953
* Check/set if options can be affected when saving product
939
954
*
Original file line number Diff line number Diff line change @@ -1113,6 +1113,21 @@ public function testSaveWithProvidedRequiredOptions()
1113
1113
$ this ->assertTrue ($ this ->model ->getRequiredOptions ());
1114
1114
}
1115
1115
1116
+ /**
1117
+ * Test for save method with provided options settled via magic method
1118
+ */
1119
+ public function testSaveWithProvidedRequiredOptionsValue ()
1120
+ {
1121
+ $ this ->model ->setHasOptions ("1 " );
1122
+ $ this ->model ->setRequiredOptions ("1 " );
1123
+ $ this ->model ->setData ("options " , null );
1124
+ $ this ->configureSaveTest ();
1125
+ $ this ->model ->beforeSave ();
1126
+ $ this ->model ->afterSave ();
1127
+ $ this ->assertTrue ($ this ->model ->getHasOptions ());
1128
+ $ this ->assertTrue ($ this ->model ->getRequiredOptions ());
1129
+ }
1130
+
1116
1131
public function testGetIsSalableSimple ()
1117
1132
{
1118
1133
$ typeInstanceMock =
You can’t perform that action at this time.
0 commit comments