$corehelper = Mage::helper('core');
$cheapestrate = 0;
if($_product->isSaleable())
{
	
	$_product = Mage::getModel('catalog/product')->load($_product->getId());
	$quote = Mage::getModel('sales/quote');
	$quote->getShippingAddress()->setCountryId('PL');			
	$addToCartInfo = (array) $_product->getAddToCartInfo();
	$request = new Varien_Object($addToCartInfo);
	if ($_product->getStockItem()) {
		$minimumQty = $_product->getStockItem()->getMinSaleQty();
		if($minimumQty > 0 && $request->getQty() < $minimumQty){
			$request->setQty($minimumQty);
		}
	}
	$_product->getStockItem()->setUseConfigManageStock(false);
	$_product->getStockItem()->setManageStock(false);
	$quote->addProduct($_product, $request); 
	$quote->getShippingAddress()->collectTotals();
	$quote->getShippingAddress()->setCollectShippingRates(true);
	$quote->getShippingAddress()->collectShippingRates();
	$rates = $quote->getShippingAddress()->getShippingRatesCollection();
	$_rates = array();
	if($rates->count()){
		foreach ($rates as $rate)
		{
			if((float)$rate->getPrice()>0){
				$_rates[] = $rate->getPrice();
			}
		}
		sort($_rates);
		$cheapestrate = $_rates[0];
	}

Leave a reply

Your email address will not be published.