Пример #1
0
 /**
  * Get product type by name. If type not exists - create new one.
  * @param $name
  * @return int
  */
 public function getTypeIdByName($name)
 {
     if (isset($this->productTypeCache[$name])) {
         return $this->productTypeCache[$name];
     }
     $model = ShopProductType::model()->findByAttributes(array('name' => $name));
     if (!$model) {
         $model = new ShopProductType();
         $model->name = $name;
         $model->save();
     }
     $this->productTypeCache[$name] = $model->id;
     return $model->id;
 }