If you got the product id then you can get details of a product by using the following method in magento.
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id); // Enter your Product Id in $product_id
// get Product's name
echo $_product->getName();
//get product's short description
echo $_product->getShortDescription();
//get Product's Long Description
echo $_product->getDescription();
//get Product's Regular Price
echo $_product->getPrice();
//get Product's Special price
echo $_product->getSpecialPrice();
//get Product's Url
echo $_product->getProductUrl();
//get Product's image Url
echo $_product->getImageUrl();
Nice post.
ReplyDeleteJust one thing:
How can I format the price I get using your explanation?
The price value I get is like 119.8400.
It has not currency symbol and has four decimals instead of two.
Thanks
getPrice(), true); # For Ex. 119.8400
Deletefunction format_money_price($number, $fractional=false) {
if ($fractional) {
$number = sprintf('%.2f', $number);
}
while (true) {
$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
if ($replaced != $number) {
$number = $replaced;
} else {
break;
}
}
return $number;
}
?>
To format price, use:
Delete$helper = Mage::helper('core')->formatPrice($price,true);
Note: here I have used $price for product price.
Nice Post!! Thanks...
ReplyDeleteI need to display add to cart button for each product. How?
ReplyDelete<input type="button" value="Add To Cart" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"/>
DeleteNice post! Its working....
ReplyDeleteHow to Get Product details Using Product Id in Magento dynamically plz help me
ReplyDeletesomebody knows how to get the credit card number and cvv after checkout, in a redirection payment api ?
ReplyDeletecan this be used to get any other attribute values ? how do you identify the attribute id/label ?
ReplyDelete