Add To Cart Url is not working with Magento Version 1.8



Some days ago our one client has sent us an email that Add To Cart Button is not working with the 1.8, actually we have developed an extension for the client and he is selling that extension to there customer and Add To Cart Button was working properly with all the prior version of the Magento but not working on the Magnto version1.8. I have checked that extension and there was the syntax for Adding the products in to the cart was
<?php
	$cartURL = "'".Mage::getUrl('checkout/cart/add', array('product' => $_product->getId(),'qty'=>1))."'";
?>

After doing some reaesrch on the Google I found the solutions given below:

<?php
	$storeId = Mage::app()->getStore()->getId();
	$catalog = $this->getLayout()->createBlock('catalog/product_list')->setStoreId($storeId);
	$cartURL = "'".$catalog->getAddToCartUrl($_product)."'";
?>

I have replaced the old code with the new one and now its looking like as:

<?php
//$cartURL = "'".Mage::getUrl('checkout/cart/add', array('product' => $_product->getId(),'qty'=>1))."'"; //Old Code

	$storeId = Mage::app()->getStore()->getId();
	$catalog = $this->getLayout()->createBlock('catalog/product_list')->setStoreId($storeId);
	$cartURL = "'".$catalog->getAddToCartUrl($_product)."'";
?>

Hope this will be helpfull. Thanks and enjoy the reading.