original_string: protected function validateItemsProductBundle()
      {
          $field = 'bundle';
          $value = $this->getSubmitted($field);
  
          if (empty($value)) {
              return null;
          }
  
          if (!is_array($value)) {
              $this->setErrorInvalid($field, $this->translation->text('Product bundle'));
              return false;
          }
  
          $main_product = $this->getSubmitted('product');
  
          $loaded = array();
  
          foreach ($value as $product_id) {
  
              if (isset($loaded[$product_id])) {
                  $this->setError($field, $this->translation->text('All bundled products must be unique'));
                  return false;
              }
  
              $product = $this->product->get($product_id);
  
              $loaded[$product_id] = $product;
  
              if (empty($product['status'])) {
                  $this->setError($field, $this->translation->text('Some of bundled products are unavailable'));
                  return false;
              }
  
              if ($main_product['product_id'] == $product['product_id']) {
                  $this->setError($field, $this->translation->text('Bundled products cannot be the same as the main product'));
                  return false;
              }
  
              if ($main_product['store_id'] != $product['store_id']) {
                  $this->setError($field, $this->translation->text('All bundled products must belong to the same store'));
                  return false;
              }
          }
  
          $this->setSubmitted('products', $loaded);
          return true;
      }
code: protected function validateItemsProductBundle()
      {
          $field = 'bundle';
          $value = $this->getSubmitted($field);
  
          if (empty($value)) {
              return null;
          }
  
          if (!is_array($value)) {
              $this->setErrorInvalid($field, $this->translation->text('Product bundle'));
              return false;
          }
  
          $main_product = $this->getSubmitted('product');
  
          $loaded = array();
  
          foreach ($value as $product_id) {
  
              if (isset($loaded[$product_id])) {
                  $this->setError($field, $this->translation->text('All bundled products must be unique'));
                  return false;
              }
  
              $product = $this->product->get($product_id);
  
              $loaded[$product_id] = $product;
  
              if (empty($product['status'])) {
                  $this->setError($field, $this->translation->text('Some of bundled products are unavailable'));
                  return false;
              }
  
              if ($main_product['product_id'] == $product['product_id']) {
                  $this->setError($field, $this->translation->text('Bundled products cannot be the same as the main product'));
                  return false;
              }
  
              if ($main_product['store_id'] != $product['store_id']) {
                  $this->setError($field, $this->translation->text('All bundled products must belong to the same store'));
                  return false;
              }
          }
  
          $this->setSubmitted('products', $loaded);
          return true;
      }
code_tokens: protected function validateItemsProductBundle ( ) { $ field = 'bundle' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) ) { return null ; } if ( ! is_array ( $ value ) ) { $ this -> setErrorInvalid ( $ field , $ this -> translation -> text ( 'Product bundle' ) ) ; return false ; } $ main_product = $ this -> getSubmitted ( 'product' ) ; $ loaded = array ( ) ; foreach ( $ value as $ product_id ) { if ( isset ( $ loaded [ $ product_id ] ) ) { $ this -> setError ( $ field , $ this -> translation -> text ( 'All bundled products must be unique' ) ) ; return false ; } $ product = $ this -> product -> get ( $ product_id ) ; $ loaded [ $ product_id ] = $ product ; if ( empty ( $ product [ 'status' ] ) ) { $ this -> setError ( $ field , $ this -> translation -> text ( 'Some of bundled products are unavailable' ) ) ; return false ; } if ( $ main_product [ 'product_id' ] == $ product [ 'product_id' ] ) { $ this -> setError ( $ field , $ this -> translation -> text ( 'Bundled products cannot be the same as the main product' ) ) ; return false ; } if ( $ main_product [ 'store_id' ] != $ product [ 'store_id' ] ) { $ this -> setError ( $ field , $ this -> translation -> text ( 'All bundled products must belong to the same store' ) ) ; return false ; } } $ this -> setSubmitted ( 'products' , $ loaded ) ; return true ; }
docstring: Validates bundled products
  @return boolean|null
docstring_tokens: Validates bundled products