How to View Single Product URL Product ID via in Magento?

Hi below code for single product url. When you pass the query string in your url. You can use below code for single product url. Or you can put product id also here working fine.
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper(‘catalog/output’);

//Jai Write Below Code for Product id via getting Product URL Start

//redirect to old Product
if(isset($_GET[‘product_id’])){
$product_id = $_GET[‘product_id’];

$cProduct = Mage::getModel(“catalog/product”);
$cProduct->load($product_id);
//echo $cProduct->getImageUrl().”<br />”;
$currentProductURL = $cProduct->getProductUrl();
//echo $currentProductURL.”<br />”;

echo “<script type=’text/javascript’ language=’javascript’>window. location='”.$currentProductURL.”‘;</script>”;

}
//Jai Write Below Code for Product id via getting Product URL Start
?>

I have small knowledge in magento. So, I more then 3 hours spent for this code getting. If anyone find this post. This is useful for you.

thanks.

Leave a Reply

© 2020 Spirituality