You can use
get_page_by_path() – don’t let the name fool you, third argument is the post type:
if ( $post = get_page_by_path( 'the_slug', OBJECT, 'post_type' ) )
$id = $post->ID;
$id = 0;
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.