original_string: protected function validateCombinationProduct()
      {
          $combinations = $this->getSubmitted('combination');
  
          if (empty($combinations)) {
              return null;
          }
  
          $index = 1;
  
          foreach ($combinations as &$combination) {
  
              $combination['status'] = !empty($combination['status']);
  
              $this->validateCombinationOptionsProduct($index, $combination);
  
              if ($this->isError("combination.$index")) {
                  continue;
              }
  
              if (empty($combination['fields'])) {
                  unset($combinations[$index]);
                  continue;
              }
  
              $combination_id = $this->sku->getCombinationId($combination['fields']);
  
              if (isset($this->processed_combinations[$combination_id])) {
                  $error = $this->translation->text('Combination already exists');
                  $this->setError("combination.$index.exists", $error);
              }
  
              $this->validateCombinationSkuProduct($index, $combination);
              $this->validateCombinationPriceProduct($index, $combination);
              $this->validateCombinationStockProduct($index, $combination);
  
              foreach ($combination['fields'] as $field_value_id) {
                  if (!isset($this->stock_amount[$field_value_id])) {
                      $this->stock_amount[$field_value_id] = (int) $combination['stock'];
                  }
              }
  
              $this->processed_combinations[$combination_id] = true;
              $index++;
          }
  
          if ($this->isError()) {
              return false;
          }
  
          $this->setSubmitted('combination', $combinations);
          $this->setSubmitted('stock', array_sum($this->stock_amount));
          return true;
      }
code: protected function validateCombinationProduct()
      {
          $combinations = $this->getSubmitted('combination');
  
          if (empty($combinations)) {
              return null;
          }
  
          $index = 1;
  
          foreach ($combinations as &$combination) {
  
              $combination['status'] = !empty($combination['status']);
  
              $this->validateCombinationOptionsProduct($index, $combination);
  
              if ($this->isError("combination.$index")) {
                  continue;
              }
  
              if (empty($combination['fields'])) {
                  unset($combinations[$index]);
                  continue;
              }
  
              $combination_id = $this->sku->getCombinationId($combination['fields']);
  
              if (isset($this->processed_combinations[$combination_id])) {
                  $error = $this->translation->text('Combination already exists');
                  $this->setError("combination.$index.exists", $error);
              }
  
              $this->validateCombinationSkuProduct($index, $combination);
              $this->validateCombinationPriceProduct($index, $combination);
              $this->validateCombinationStockProduct($index, $combination);
  
              foreach ($combination['fields'] as $field_value_id) {
                  if (!isset($this->stock_amount[$field_value_id])) {
                      $this->stock_amount[$field_value_id] = (int) $combination['stock'];
                  }
              }
  
              $this->processed_combinations[$combination_id] = true;
              $index++;
          }
  
          if ($this->isError()) {
              return false;
          }
  
          $this->setSubmitted('combination', $combinations);
          $this->setSubmitted('stock', array_sum($this->stock_amount));
          return true;
      }
code_tokens: protected function validateCombinationProduct ( ) { $ combinations = $ this -> getSubmitted ( 'combination' ) ; if ( empty ( $ combinations ) ) { return null ; } $ index = 1 ; foreach ( $ combinations as & $ combination ) { $ combination [ 'status' ] = ! empty ( $ combination [ 'status' ] ) ; $ this -> validateCombinationOptionsProduct ( $ index , $ combination ) ; if ( $ this -> isError ( "combination.$index" ) ) { continue ; } if ( empty ( $ combination [ 'fields' ] ) ) { unset ( $ combinations [ $ index ] ) ; continue ; } $ combination_id = $ this -> sku -> getCombinationId ( $ combination [ 'fields' ] ) ; if ( isset ( $ this -> processed_combinations [ $ combination_id ] ) ) { $ error = $ this -> translation -> text ( 'Combination already exists' ) ; $ this -> setError ( "combination.$index.exists" , $ error ) ; } $ this -> validateCombinationSkuProduct ( $ index , $ combination ) ; $ this -> validateCombinationPriceProduct ( $ index , $ combination ) ; $ this -> validateCombinationStockProduct ( $ index , $ combination ) ; foreach ( $ combination [ 'fields' ] as $ field_value_id ) { if ( ! isset ( $ this -> stock_amount [ $ field_value_id ] ) ) { $ this -> stock_amount [ $ field_value_id ] = ( int ) $ combination [ 'stock' ] ; } } $ this -> processed_combinations [ $ combination_id ] = true ; $ index ++ ; } if ( $ this -> isError ( ) ) { return false ; } $ this -> setSubmitted ( 'combination' , $ combinations ) ; $ this -> setSubmitted ( 'stock' , array_sum ( $ this -> stock_amount ) ) ; return true ; }
docstring: Validates an array of product combinations
  @return boolean|null
docstring_tokens: Validates an array of product combinations