original_string: protected function validateCategoryProduct()
      {
          $fields = array(
              'category_id' => $this->translation->text('Category'),
              'brand_category_id' => $this->translation->text('Brand'),
          );
  
          $errors = 0;
  
          foreach ($fields as $field => $label) {
  
              $value = $this->getSubmitted($field);
  
              if (!isset($value)) {
                  continue;
              }
  
              if (!is_numeric($value)) {
                  $errors++;
                  $this->setErrorNumeric($field, $label);
                  continue;
              }
  
              if (empty($value)) {
                  continue;
              }
  
              $category = $this->category->get($value);
  
              if (empty($category['category_id'])) {
                  $errors++;
                  $this->setErrorUnavailable($field, $label);
              }
          }
  
          return empty($errors);
      }
code: protected function validateCategoryProduct()
      {
          $fields = array(
              'category_id' => $this->translation->text('Category'),
              'brand_category_id' => $this->translation->text('Brand'),
          );
  
          $errors = 0;
  
          foreach ($fields as $field => $label) {
  
              $value = $this->getSubmitted($field);
  
              if (!isset($value)) {
                  continue;
              }
  
              if (!is_numeric($value)) {
                  $errors++;
                  $this->setErrorNumeric($field, $label);
                  continue;
              }
  
              if (empty($value)) {
                  continue;
              }
  
              $category = $this->category->get($value);
  
              if (empty($category['category_id'])) {
                  $errors++;
                  $this->setErrorUnavailable($field, $label);
              }
          }
  
          return empty($errors);
      }
code_tokens: protected function validateCategoryProduct ( ) { $ fields = array ( 'category_id' => $ this -> translation -> text ( 'Category' ) , 'brand_category_id' => $ this -> translation -> text ( 'Brand' ) , ) ; $ errors = 0 ; foreach ( $ fields as $ field => $ label ) { $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { continue ; } if ( ! is_numeric ( $ value ) ) { $ errors ++ ; $ this -> setErrorNumeric ( $ field , $ label ) ; continue ; } if ( empty ( $ value ) ) { continue ; } $ category = $ this -> category -> get ( $ value ) ; if ( empty ( $ category [ 'category_id' ] ) ) { $ errors ++ ; $ this -> setErrorUnavailable ( $ field , $ label ) ; } } return empty ( $ errors ) ; }
docstring: Validates product categories
  @return boolean
docstring_tokens: Validates product categories