<?php
global $post;
$post_slug = $post->post_name;
?>
function get_post_by_slug($slug){
$posts = get_posts(array(
'name' => $slug,
'posts_per_page' => 1,
'post_type' => 'product',
'post_status' => 'publish'
));
if(! $posts ) {
throw new Exception("NoSuchPostBySpecifiedID");
}
return $post[0];
}