Tuesday 25 June 2013

Get all Product type's price show in homepage in magento

Get Simple Product Price in Homepage

<?php echo $_product->getFormatedprice(); ?>

Get Group Product Price in Homepage


<?php  
    $aProductIds = $_product->getTypeInstance()->getChildrenIds($_productl->getId());
    $prices = array();
    foreach ($aProductIds as $ids) {
           foreach ($ids as $id) {
                  $aProduct = Mage::getModel('catalog/product')->load($id);
                  $prices[] = $aProduct->getPriceModel()->getPrice($aProduct);
            }
     }
     //krsort($prices);
     asort($prices);
     echo $_product->setPrice(array_shift($prices));
   ?>


Get Bundle Product (Maximum and Minimum) Price in Homepage


      $_product_id            = $_product->getId();  //Here bundle Product id


//$return_type  select which you want to get price. If you want to get Max Price, you will add $return_type = ‘max’. And if you want to get minimum Price of product, you will add $return_type = ‘min’


      // highest possible price for this bundle product
      //$return_type            = 'max';
     
            // lowest possible price for this bundle product
       $return_type         = 'min';
     
      $model_catalog_product  = Mage::getModel('catalog/product'); // getting product model
      $_product               = $model_catalog_product->load( $_product_id );
      $TypeInstance           = $_product->getTypeInstance(true);
$Selections             = $TypeInstance->getSelectionsCollection($OptionIds, $_product );
$Options                = $TypeInstance->getOptionsByIds($OptionIds, $_product);
$bundleOptions          = $Options->appendSelections($Selections, true);
     
$minmax_pricevalue  = 0; // to sum them up from 0
     
foreach ($bundleOptions as $bundleOption) {
      if ($bundleOption->getSelections()) {
          $bundleSelections       = $bundleOption->getSelections();
          $pricevalues_array  = array();
          foreach ($bundleSelections as $bundleSelection) {
              $pricevalues_array[] = $bundleSelection->getPrice();
          }
          if ( $return_type == 'max' ) {
              rsort($pricevalues_array); // high to low
          } else {
              sort($pricevalues_array);   // low to high
          }
          // sum up the highest possible or lowest possible price
          $minmax_pricevalue += $pricevalues_array[0];
      }
  }
// echo $minmax_pricevalue;  //Get minimum price value
echo 'As low as '.Mage::helper('core')->currency($minmax_pricevalue, true, false);   //Get minimum price value with store currency.


Get Configurable Product Price in Homepage


$product = Mage::getModel('catalog/product')->load($_product->getId());
//load all children
$childProducts = Mage::getModel('catalog/product_type_configurable')
           ->getUsedProducts(null,$product);
$childPrice = array();
foreach($childProducts as $child){
    $_child = Mage::getModel('catalog/product')->load($child->getId());
    $childPrice[] =  $_child->getPrice();
}
//If you want to minimum price of product use this
echo min($childPrice);


//If you want to maximum price of product use this
echo max($childPrice);

No comments:

Post a Comment

Thanks for visit blog.