protected function parseSubCategories($response, $parent_id) { $parser = new NewhtfSubCategoryParser($response); foreach ($parser->categories as $c_data) { $category_entity = CategoryModel::findOneByUrl($c_data['url']); if (!$category_entity) { $category_entity = new Category(); } $c_data['parent_id'] = $parent_id; $category_entity->fromArray($c_data); $category_entity->save(); } }