@@ -49,7 +49,7 @@ public function __construct(
49
49
* @param ProductRepositoryInterface $subject
50
50
* @param ProductInterface $product
51
51
* @param bool $saveOptions
52
- * @return array
52
+ * @return void
53
53
* @throws InputException
54
54
* @throws NoSuchEntityException
55
55
*
@@ -59,34 +59,24 @@ public function beforeSave(
59
59
ProductRepositoryInterface $ subject ,
60
60
ProductInterface $ product ,
61
61
$ saveOptions = false
62
- ): array {
63
- $ result = [$ product , $ saveOptions ];
64
- if ($ product ->getTypeId () !== Configurable::TYPE_CODE ) {
65
- return $ result ;
66
- }
67
-
68
- $ extensionAttributes = $ product ->getExtensionAttributes ();
69
- if ($ extensionAttributes === null ) {
70
- return $ result ;
71
- }
72
-
73
- $ configurableLinks = (array ) $ extensionAttributes ->getConfigurableProductLinks ();
74
- $ configurableOptions = (array ) $ extensionAttributes ->getConfigurableProductOptions ();
62
+ ): void {
63
+ if ($ product ->getTypeId () === Configurable::TYPE_CODE
64
+ && null !== ($ extensionAttributes = $ product ->getExtensionAttributes ())
65
+ ) {
66
+ $ configurableLinks = (array ) $ extensionAttributes ->getConfigurableProductLinks ();
67
+ $ configurableOptions = (array ) $ extensionAttributes ->getConfigurableProductOptions ();
75
68
76
- if (empty ($ configurableLinks ) && empty ($ configurableOptions )) {
77
- return $ result ;
78
- }
79
-
80
- $ attributeCodes = [] ;
81
- /** @var OptionInterface $configurableOption */
82
- foreach ( $ configurableOptions as $ configurableOption ) {
83
- $ eavAttribute = $ this -> productAttributeRepository -> get ( $ configurableOption -> getAttributeId ());
84
- $ attributeCode = $ eavAttribute -> getAttributeCode ( );
85
- $ attributeCodes [] = $ attributeCode ;
69
+ if (! empty ($ configurableLinks ) && ! empty ($ configurableOptions )) {
70
+ $ attributeCodes = [] ;
71
+ /** @var OptionInterface $configurableOption */
72
+ foreach ( $ configurableOptions as $ configurableOption ) {
73
+ $ eavAttribute = $ this -> productAttributeRepository -> get ( $ configurableOption -> getAttributeId ()) ;
74
+ $ attributeCode = $ eavAttribute -> getAttributeCode ();
75
+ $ attributeCodes [] = $ attributeCode ;
76
+ }
77
+ $ this -> validateProductLinks ( $ attributeCodes , $ configurableLinks );
78
+ }
86
79
}
87
- $ this ->validateProductLinks ($ attributeCodes , $ configurableLinks );
88
-
89
- return $ result ;
90
80
}
91
81
92
82
/**
0 commit comments