File tree Expand file tree Collapse file tree 2 files changed +10
-18
lines changed
app/code/Magento/Catalog/Model
dev/tests/integration/testsuite/Magento/Catalog/Model/Product Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -2030,9 +2030,11 @@ public function getOptions()
2030
2030
*/
2031
2031
public function setOptions (array $ options = null )
2032
2032
{
2033
- foreach ($ options as $ option ) {
2034
- if ($ option instanceof \Magento \Catalog \Api \Data \ProductCustomOptionInterface) {
2035
- $ option ->setProduct ($ this );
2033
+ if ($ options ) {
2034
+ foreach ($ options as $ option ) {
2035
+ if ($ option instanceof \Magento \Catalog \Api \Data \ProductCustomOptionInterface) {
2036
+ $ option ->setProduct ($ this );
2037
+ }
2036
2038
}
2037
2039
}
2038
2040
$ this ->setData ('options ' , $ options );
Original file line number Diff line number Diff line change @@ -230,7 +230,11 @@ public function testCreateOptionsWithTypeDate(array $optionData): void
230
230
*/
231
231
public function testCreateOptionWithError (array $ optionData , \Exception $ expectedErrorObject ): void
232
232
{
233
- $ product = $ this ->productRepository ->get ('simple ' );
233
+ /**
234
+ * storeId == 0 required for 'error_option_without_title' test case.
235
+ * See \Magento\Catalog\Model\Product\Option\Validator\DefaultValidator::isValidOptionTitle.
236
+ */
237
+ $ product = $ this ->productRepository ->get ('simple ' , false , 0 );
234
238
$ createdOption = $ this ->customOptionFactory ->create (['data ' => $ optionData ]);
235
239
$ product ->setOptions ([$ createdOption ]);
236
240
$ this ->expectExceptionObject ($ expectedErrorObject );
@@ -811,20 +815,6 @@ public function productCustomOptionsTypeDateDataProvider(): array
811
815
public function productCustomOptionsWithErrorDataProvider (): array
812
816
{
813
817
return [
814
- 'error_option_without_product_sku ' => [
815
- [
816
- 'record_id ' => 0 ,
817
- 'sort_order ' => 1 ,
818
- 'is_require ' => 1 ,
819
- 'sku ' => 'test-option-title-1 ' ,
820
- 'max_characters ' => 50 ,
821
- 'title ' => 'Test option title 1 ' ,
822
- 'type ' => 'area ' ,
823
- 'price ' => 10 ,
824
- 'price_type ' => 'fixed ' ,
825
- ],
826
- new CouldNotSaveException (__ ('The ProductSku is empty. Set the ProductSku and try again. ' )),
827
- ],
828
818
'error_option_without_type ' => [
829
819
[
830
820
'record_id ' => 0 ,
You can’t perform that action at this time.
0 commit comments