public static function find_by_name($name) { include WCAPIDIR . "/_globals.php"; include WCAPIDIR . "/_model_static_attributes.php"; $sql = "\n SELECT\n categories.*,\n taxons.term_taxonomy_id,\n taxons.description,\n taxons.parent,\n taxons.count\n FROM\n wp_terms as categories,\n wp_term_taxonomy as taxons\n WHERE\n (taxons.taxonomy = 'product_cat') and\n (categories.term_id = taxons.term_id) and\n (categories.name = %s)\n "; $sql = $wpdb->prepare($sql, $name); $results = $wpdb->get_results($sql, 'ARRAY_A'); $category = new Category(); $first = $results[0]; if ($first) { $category->setValid(true); foreach ($self->attributes_table as $name => $desc) { $category->dynamic_set($name, $desc, $first[$desc['name']], null); } } return $category; }