Magento - show the stock indicator on product list - magento

how can I show the stock indicator on Magento product list ?
Thanks a lot.

To show the quantity of items left in stock use this:
<?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); ?>

Related

Magento: price on cart is from configurable product, not from simple-product

I had a similar problem last time, but the solution just helps with my test-product, whre I can add price +/- in my configurable product. Price in Cart is not correct Magento 1.8
Is it possible to take the price of the simple product, without adding some prices +/- at the configurable one?
On cart I get the SKU of the simple-product, but with $_item->getPrice() I only get the Price of the configurable product.
Thanks for help!
Use the sku of the item to load the simple product, for example:
$_productSku = $_item->getSku();
$_product = Mage::getModel('catalog/product');
$_productId = $_product->getIdBySku($_productSku);
$_product->load($_productId);
then use
$_product->getPrice();
Regards
Hans
Shorter solution is:
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku());
$_product->getPrice();

magento add tax on custom attribute based price

we sell bunch of product and we need to display each price product and entire box price.For that reason i have created attribute with each price and calling it on product page.So main price of product will be box price and each price will be display from attribute.but now i when i add tax i can see the main price with excluding and including tax but how to apply that tax on attribute based price?
this would be each product price
<?php echo $_product->getResource()->getAttribute('each_price')->getFrontend()- >getValue($_product)?>
this would be whole box price
<?php echo $this->getPriceHtml($_product, true);?>
some thing like this can be done to achive this.please look the code below
<?php $txrate= $_product->getData('tax_percent');
if($txrate!=""):
echo '<div class="each-inc-tax">';
$ech_price= $_product->getResource()->getAttribute('each_price')->getFrontend()->getValue($_product);
$tx=($txrate*$ech_price)/100;
$each_tax=$ech_price+$tx;
echo ' <b>Each Price Including Tax:</b> <b>'. $each_tax.'</b>';
echo '</div>';
endif;
I was using the MSRP attribute in my magento and storing the value excluding Tax, but wishing to display on the frontend including Tax.
I used the following code...
<?php
$_finalPriceExclTax = $this->helper('tax')->getPrice($_product, $_product->getPrice(), false);
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true);
$_taxpercent = $_finalPriceInclTax / $_finalPriceExclTax;
$_msrpPrice = $_product->getMsrp() * $_taxpercent;
?>

magento minimal price of grouped product

I want to display minimal price of grouped product in our magento online shop. I used
<?php echo $this->getPriceHtml($_product, true) ?>
But it does not work for grouped product. It only works for simple product.
$_product->getMinimalPrice () ;

Checking additional conditions for product price in magento

In my magento site i added number of products with price as 0.00.
Now that products are displayed with price as $0.00.
so i want to display the price as not mentioned instead of $0.00.
How can i do this?
the price.phtml what is the condition i need to write for that?
My condition is:
if price == 0.00 display the text 'not mentioned'
try this.
<?php
if ((int)$this->getPrice()){
echo $this->getPrice();
}else {
echo "not mentioned";
}
?>
correct me if i am wrong.
^^

Magento: Get Product Backordered Quantity in New Order Email

I'm trying to add the number of backorder products to the email template that comes out in the new order email.
So far I've managed to get the product but I just can't seem to get it's quantity. I've tried a variety of methods but nothing seems to work. Here is my latest attempt:
The file is app/design/frontend/base/default/template/email/order/items/order/default/phtml
<?php
// 1. Get Qty of Product in Store.
// 2. Get Qty of product from order
// 3. IF qty from order > qty in store then get number over
// 4. Display number over
$_sku = $this->getItem()->getSku();
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_sku);
//print_r($_product);
echo 'qty in shop: '.$qtyInStock = $_product->getStockItem()->getQty(); //debugging
echo 'qty ordered: '.$qtyOrdered = $_item->getQtyOrdered()*1; //debugging
?>
<?php if($qtyOrdered > $qtyInStock): $back_order = $qtyOrdered - $qtyInStock; ?>
<p>* This product is not available in the requested quantity. <?php echo $back_order; ?> of the item(s) will be backordered.</p>
<?php endif; ?>
I'm not finished with the logic yet. I'm just stuck on getting the products quantity.
$_product->getStockItem()->getQty();
Any help most appreciated.
Billy
Found a solution:
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_sku);
$stock_count = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
Seems quite roundabout but it does the job.
Feel free to suggest better...

Resources