Magento : get product detail by product Id or product name

Product detail by product ID
load($productid); //getting product object for particular product id
echo $_product->getShortDescription(); //product’s short description
echo $_product->getDescription(); // product’s long description
echo $_product->getName(); //product name

echo $_product->getPrice(); //product’s regular Price

echo $_product->getSpecialPrice(); //product’s special Price

echo $_product->getProductUrl(); //product url

echo $_product->getImageUrl(); //product’s image url

echo $_product->getSmallImageUrl(); //product’s small image url

echo $_product->getThumbnailUrl(); //product’s thumbnail image url

Product detail by product Name
getCollection(); //products collection

foreach ($collection as $product) //loop for getting products


$pname = $model->getName();



$id = $product->getId();


echo ‘Required ID->’.$id; //id of product?>


Magento : Show recent view product in product view page in magento

What I have done to enable recently viewed on the product page was:
in catalog.xml inside the content block of catalog_product_view:

<block type="reports/product_viewed" name="reports.product.viewed" 
 as="recently_viewed" template="reports/product_viewed.phtml">
  <action method="setColumnCount"><columns>4</columns></action>
  <action method="setItemLimit"><type>recently_viewed</type><limit>4</limit></action>
in the template file: catalog/product/view.phtml:
<?php echo $this->getChildHtml('recently_viewed') ?>