@@ -49,7 +49,7 @@ public function __construct(
4949 * @param ProductRepositoryInterface $subject
5050 * @param ProductInterface $product
5151 * @param bool $saveOptions
52- * @return array
52+ * @return void
5353 * @throws InputException
5454 * @throws NoSuchEntityException
5555 *
@@ -59,34 +59,24 @@ public function beforeSave(
5959 ProductRepositoryInterface $ subject ,
6060 ProductInterface $ product ,
6161 $ 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 ();
7568
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+ }
8679 }
87- $ this ->validateProductLinks ($ attributeCodes , $ configurableLinks );
88-
89- return $ result ;
9080 }
9181
9282 /**
0 commit comments