File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
app/code/Magento/Bundle/Model/Product Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -47,19 +47,19 @@ public function __construct(
47
47
*/
48
48
public function execute ($ entity , $ arguments = [])
49
49
{
50
- if ($ entity ->getTypeId () !== Type::TYPE_CODE ) {
50
+ $ bundleProductOptions = $ entity ->getExtensionAttributes ()->getBundleProductOptions ();
51
+ if ($ entity ->getTypeId () !== Type::TYPE_CODE || empty ($ bundleProductOptions )) {
51
52
return $ entity ;
52
53
}
53
54
54
55
$ existingBundleProductOptions = $ this ->optionRepository ->getList ($ entity ->getSku ());
55
- $ bundleProductOptions = $ entity ->getExtensionAttributes ()->getBundleProductOptions ();
56
-
57
- if (empty ($ existingBundleProductOptions ) && empty ($ bundleProductOptions )) {
58
- return $ entity ;
59
- }
60
56
61
- $ existingOptionsIds = $ this ->getOptionIds ($ existingBundleProductOptions );
62
- $ optionIds = $ this ->getOptionIds ($ bundleProductOptions );
57
+ $ existingOptionsIds = !empty ($ existingBundleProductOptions )
58
+ ? $ this ->getOptionIds ($ existingBundleProductOptions )
59
+ : [];
60
+ $ optionIds = !empty ($ bundleProductOptions )
61
+ ? $ this ->getOptionIds ($ bundleProductOptions )
62
+ : [];
63
63
64
64
$ options = $ bundleProductOptions ?: [];
65
65
@@ -116,6 +116,11 @@ private function saveOptions($entity, $options)
116
116
private function getOptionIds ($ options )
117
117
{
118
118
$ optionIds = [];
119
+
120
+ if (empty ($ options )) {
121
+ return $ optionIds ;
122
+ }
123
+
119
124
/** @var \Magento\Bundle\Api\Data\OptionInterface $option */
120
125
foreach ($ options as $ option ) {
121
126
if ($ option ->getOptionId ()) {
You can’t perform that action at this time.
0 commit comments