0

I have a CMS page and would like to add current pricing and display available quantity available called from the product SKU. There is a product ID for each product. The code below is from the category page. What is the code to display the following:

Product price

<?php 
if($prd_price == 1){
echo $this->getPriceHtml($_product, true); 
} 
?>

Qty available inventory

<?php echo($_product->getSku()); ?></td> Available Units: <?php echo $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct ($_product); echo round($stock->getQty()); ?> 

Thank you.

1

You have to create a custom Magento widget loading information from product and showing them using a template.

Have a look on how to build a custom widget from this link: http://www.cloudways.com/blog/create-custom-widget-magento/

You should simply load the product information from the product id and display them.

| improve this answer | |
  • Thank you @RiccardoT What is the code to load the product price and inventory information? – Elvis Feb 16 '16 at 17:01
  • Simply use the following code to get both ot them: $product = Mage::getModel('catalog/product')->load($productId); $stockQty= Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty(); $price = $product->getFinalPrice(); – Phoenix128_RiccardoT Feb 16 '16 at 17:07
  • If you wish to load from product SKU instead of product ID replace the load line with: Mage::getModel('catalog/product')->load($productSku, 'sku'); – Phoenix128_RiccardoT Feb 16 '16 at 17:12
  • Thank you @RiccardoT. I followed the widget instructions and having trouble loading the code block/filename.php. What is the code example? I don't see anything on the frontend webpage. – Elvis Feb 16 '16 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.