@@ -416,16 +416,13 @@ public function beforeSave($product)
416
416
if ($ product ->getCanSaveBundleSelections ()) {
417
417
$ product ->canAffectOptions (true );
418
418
$ selections = $ product ->getBundleSelectionsData ();
419
- if ($ selections && !empty ($ selections )) {
420
- $ options = $ product ->getBundleOptionsData ();
421
- if ($ options ) {
422
- foreach ($ options as $ option ) {
423
- if (empty ($ option ['delete ' ]) || 1 != (int )$ option ['delete ' ]) {
424
- $ product ->setTypeHasOptions (true );
425
- if (1 == (int )$ option ['required ' ]) {
426
- $ product ->setTypeHasRequiredOptions (true );
427
- break ;
428
- }
419
+ if (!empty ($ selections ) && $ options = $ product ->getBundleOptionsData ()) {
420
+ foreach ($ options as $ option ) {
421
+ if (empty ($ option ['delete ' ]) || 1 != (int )$ option ['delete ' ]) {
422
+ $ product ->setTypeHasOptions (true );
423
+ if (1 == (int )$ option ['required ' ]) {
424
+ $ product ->setTypeHasRequiredOptions (true );
425
+ break ;
429
426
}
430
427
}
431
428
}
@@ -461,7 +458,7 @@ public function getOptionsIds($product)
461
458
* Retrieve bundle option collection
462
459
*
463
460
* @param \Magento\Catalog\Model\Product $product
464
- * @return Collection
461
+ * @return \Magento\Bundle\Model\ResourceModel\Option\ Collection
465
462
*/
466
463
public function getOptionsCollection ($ product )
467
464
{
@@ -532,10 +529,10 @@ public function getSelectionsCollection($optionIds, $product)
532
529
* Example: the catalog inventory validation of decimal qty can change qty to int,
533
530
* so need to change quote item qty option value too.
534
531
*
535
- * @param array $options
536
- * @param \Magento\Framework\DataObject $option
537
- * @param mixed $value
538
- * @param \Magento\Catalog\Model\Product $product
532
+ * @param array $options
533
+ * @param \Magento\Framework\DataObject $option
534
+ * @param mixed $value
535
+ * @param \Magento\Catalog\Model\Product $product
539
536
* @return $this
540
537
*/
541
538
public function updateQtyOption ($ options , \Magento \Framework \DataObject $ option , $ value , $ product )
@@ -894,7 +891,7 @@ public function getSelectionsByIds($selectionIds, $product)
894
891
*
895
892
* @param array $optionIds
896
893
* @param \Magento\Catalog\Model\Product $product
897
- * @return Collection
894
+ * @return \Magento\Bundle\Model\ResourceModel\Option\ Collection
898
895
*/
899
896
public function getOptionsByIds ($ optionIds , $ product )
900
897
{
@@ -1191,9 +1188,11 @@ public function canConfigure($product)
1191
1188
* @return void
1192
1189
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
1193
1190
*/
1191
+ // @codingStandardsIgnoreStart
1194
1192
public function deleteTypeSpecificData (\Magento \Catalog \Model \Product $ product )
1195
1193
{
1196
1194
}
1195
+ // @codingStandardsIgnoreEnd
1197
1196
1198
1197
/**
1199
1198
* Return array of specific to type product entities
@@ -1203,18 +1202,19 @@ public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product)
1203
1202
*/
1204
1203
public function getIdentities (\Magento \Catalog \Model \Product $ product )
1205
1204
{
1206
- $ identities = parent ::getIdentities ($ product );
1205
+ $ identities = [];
1206
+ $ identities [] = parent ::getIdentities ($ product );
1207
1207
/** @var \Magento\Bundle\Model\Option $option */
1208
1208
foreach ($ this ->getOptions ($ product ) as $ option ) {
1209
1209
if ($ option ->getSelections ()) {
1210
1210
/** @var \Magento\Catalog\Model\Product $selection */
1211
1211
foreach ($ option ->getSelections () as $ selection ) {
1212
- $ identities = array_merge ( $ identities , $ selection ->getIdentities () );
1212
+ $ identities[] = $ selection ->getIdentities ();
1213
1213
}
1214
1214
}
1215
1215
}
1216
1216
1217
- return $ identities ;
1217
+ return array_merge ([], ... $ identities) ;
1218
1218
}
1219
1219
1220
1220
/**
@@ -1261,7 +1261,7 @@ protected function getBeforeQty($product, $selection)
1261
1261
*
1262
1262
* @param \Magento\Catalog\Model\Product $product
1263
1263
* @param bool $isStrictProcessMode
1264
- * @param Collection $optionsCollection
1264
+ * @param \Magento\Bundle\Model\ResourceModel\Option\ Collection $optionsCollection
1265
1265
* @param int[] $options
1266
1266
* @return void
1267
1267
* @throws \Magento\Framework\Exception\LocalizedException
@@ -1331,7 +1331,7 @@ private function isSelectedOptionValid($option, $options): bool
1331
1331
*
1332
1332
* @param \Magento\Bundle\Model\ResourceModel\Selection\Collection $selections
1333
1333
* @param bool $skipSaleableCheck
1334
- * @param Collection $optionsCollection
1334
+ * @param \Magento\Bundle\Model\ResourceModel\Option\ Collection $optionsCollection
1335
1335
* @param int[] $options
1336
1336
* @return void
1337
1337
* @throws \Magento\Framework\Exception\LocalizedException
@@ -1387,16 +1387,18 @@ protected function checkIsResult($_result)
1387
1387
*/
1388
1388
protected function mergeSelectionsWithOptions ($ options , $ selections )
1389
1389
{
1390
+ $ selections = [];
1391
+
1390
1392
foreach ($ options as $ option ) {
1391
1393
$ optionSelections = $ option ->getSelections ();
1392
1394
if ($ option ->getRequired () && is_array ($ optionSelections ) && count ($ optionSelections ) == 1 ) {
1393
- $ selections = array_merge ( $ selections , $ optionSelections) ;
1395
+ $ selections[] = $ optionSelections ;
1394
1396
} else {
1395
1397
$ selections = [];
1396
1398
break ;
1397
1399
}
1398
1400
}
1399
1401
1400
- return $ selections ;
1402
+ return array_merge ([], ... $ selections) ;
1401
1403
}
1402
1404
}
0 commit comments