private function findType(&$data)
 {
     static $types = array();
     /**
      * @var shopTypeModel $model
      */
     static $model;
     if (!empty($data['type_name'])) {
         $type = mb_strtolower(self::flatData($data['type_name']));
         if (!isset($types[$type])) {
             if (!$model) {
                 $model = new shopTypeModel();
             }
             if ($type_row = $model->getByName($type)) {
                 $types[$type] = $type_row['id'];
             } else {
                 if (!$this->data['rights']) {
                     $types[$type] = $data['type_id'] = false;
                 } else {
                     $types[$type] = $model->insert(array('name' => $data['type_name']));
                     if (empty($this->data['types'])) {
                         $this->data['types'] = array();
                     }
                     $this->data['types'][] = intval($types[$type]);
                 }
             }
         }
         $data['type_id'] = $types[$type];
     } else {
         $data['type_id'] = ifempty($data['type_id'], $this->data['type_id']);
     }
     if (isset($data['type_name'])) {
         unset($data['type_name']);
     }
     /* check rights per product type */
     return in_array($data['type_id'], $this->data['types']);
 }