@@ -416,16 +416,13 @@ public function beforeSave($product)
416416 if ($ product ->getCanSaveBundleSelections ()) {
417417 $ product ->canAffectOptions (true );
418418 $ 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 ;
429426 }
430427 }
431428 }
@@ -461,7 +458,7 @@ public function getOptionsIds($product)
461458 * Retrieve bundle option collection
462459 *
463460 * @param \Magento\Catalog\Model\Product $product
464- * @return Collection
461+ * @return \Magento\Bundle\Model\ResourceModel\Option\ Collection
465462 */
466463 public function getOptionsCollection ($ product )
467464 {
@@ -532,10 +529,10 @@ public function getSelectionsCollection($optionIds, $product)
532529 * Example: the catalog inventory validation of decimal qty can change qty to int,
533530 * so need to change quote item qty option value too.
534531 *
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
539536 * @return $this
540537 */
541538 public function updateQtyOption ($ options , \Magento \Framework \DataObject $ option , $ value , $ product )
@@ -894,7 +891,7 @@ public function getSelectionsByIds($selectionIds, $product)
894891 *
895892 * @param array $optionIds
896893 * @param \Magento\Catalog\Model\Product $product
897- * @return Collection
894+ * @return \Magento\Bundle\Model\ResourceModel\Option\ Collection
898895 */
899896 public function getOptionsByIds ($ optionIds , $ product )
900897 {
@@ -1191,9 +1188,11 @@ public function canConfigure($product)
11911188 * @return void
11921189 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
11931190 */
1191+ // @codingStandardsIgnoreStart
11941192 public function deleteTypeSpecificData (\Magento \Catalog \Model \Product $ product )
11951193 {
11961194 }
1195+ // @codingStandardsIgnoreEnd
11971196
11981197 /**
11991198 * Return array of specific to type product entities
@@ -1203,18 +1202,19 @@ public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product)
12031202 */
12041203 public function getIdentities (\Magento \Catalog \Model \Product $ product )
12051204 {
1206- $ identities = parent ::getIdentities ($ product );
1205+ $ identities = [];
1206+ $ identities [] = parent ::getIdentities ($ product );
12071207 /** @var \Magento\Bundle\Model\Option $option */
12081208 foreach ($ this ->getOptions ($ product ) as $ option ) {
12091209 if ($ option ->getSelections ()) {
12101210 /** @var \Magento\Catalog\Model\Product $selection */
12111211 foreach ($ option ->getSelections () as $ selection ) {
1212- $ identities = array_merge ( $ identities , $ selection ->getIdentities () );
1212+ $ identities[] = $ selection ->getIdentities ();
12131213 }
12141214 }
12151215 }
12161216
1217- return $ identities ;
1217+ return array_merge ([], ... $ identities) ;
12181218 }
12191219
12201220 /**
@@ -1261,7 +1261,7 @@ protected function getBeforeQty($product, $selection)
12611261 *
12621262 * @param \Magento\Catalog\Model\Product $product
12631263 * @param bool $isStrictProcessMode
1264- * @param Collection $optionsCollection
1264+ * @param \Magento\Bundle\Model\ResourceModel\Option\ Collection $optionsCollection
12651265 * @param int[] $options
12661266 * @return void
12671267 * @throws \Magento\Framework\Exception\LocalizedException
@@ -1331,7 +1331,7 @@ private function isSelectedOptionValid($option, $options): bool
13311331 *
13321332 * @param \Magento\Bundle\Model\ResourceModel\Selection\Collection $selections
13331333 * @param bool $skipSaleableCheck
1334- * @param Collection $optionsCollection
1334+ * @param \Magento\Bundle\Model\ResourceModel\Option\ Collection $optionsCollection
13351335 * @param int[] $options
13361336 * @return void
13371337 * @throws \Magento\Framework\Exception\LocalizedException
@@ -1387,16 +1387,18 @@ protected function checkIsResult($_result)
13871387 */
13881388 protected function mergeSelectionsWithOptions ($ options , $ selections )
13891389 {
1390+ $ selections = [];
1391+
13901392 foreach ($ options as $ option ) {
13911393 $ optionSelections = $ option ->getSelections ();
13921394 if ($ option ->getRequired () && is_array ($ optionSelections ) && count ($ optionSelections ) == 1 ) {
1393- $ selections = array_merge ( $ selections , $ optionSelections) ;
1395+ $ selections[] = $ optionSelections ;
13941396 } else {
13951397 $ selections = [];
13961398 break ;
13971399 }
13981400 }
13991401
1400- return $ selections ;
1402+ return array_merge ([], ... $ selections) ;
14011403 }
14021404}
0 commit comments