Skip to main content

How to Show product Price in product List page

first add this code block after list or grid mode wherever you want
<?php if($_product->isConfigurable()): ?>
 <?php $attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product) ?>
 <?php if(count($attributes)): ?>
<?php foreach($attributes as $att): ?>
 <?php $pAtt=$att->getProductAttribute();
//get the child products
$allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product);
$frontValues =array() ?>
  <?php //echo $pAtt->getFrontendLabel() ?>
  <?php foreach($allProducts as $p): ?>
 <?php if(!$p->isSaleable()) continue; ?>
<?php $out=$p->getAttributeText($pAtt->getName()); ?>
<?php $frontValues[$out]=$out; ?>
  <?php endforeach ?>

<?php endforeach ?>
<?php endif ?>
<?php endif ?>
<?php
/* if ($_product->getData('type_id') == "configurable"){

$z=0;
foreach ($_product->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) {

$stock = round(Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple)->getQty());

if(($current_size_filter==$size_arr[$z])){
if($stock!=0)
$sold_out_size = 'no';
else
$sold_out_size = 'yes';
}


$z++;

}
}
*/
if(isset($frontValues)){

if(isset($current_size_filter)){
if($frontValues[$current_size_filter]!=""){
$sold_out_size = 'no';
}else{
   $sold_out_size = 'yes';
}

}
}
//echo $sold_out_size;
?>
then add this code where you want to display sizes
<ul class="cat_size">
                <?php
//check if product is a configurable type or not
if ($_product->getData('type_id') == "configurable")
{  

$config = $_product->getTypeInstance(true);

foreach($config->getConfigurableAttributesAsArray($_product) as $attributes)
{
$s=0;
        //print_r($attributes);
if ($attributes["label"] != "") {

foreach($attributes["values"] as $values)
{
$size_arr[$s] = $values["label"];
$s++;
}

}
}

?>

<?php }
$j=0;
//echo $qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
//if($qtyStock>0){
if($_product->isSaleable() && $_product->getData('type_id') == "configurable") {
foreach ($_product->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) {
$stock = round(Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple)->getQty());
$size_b = $size_arr[$j];
if($frontValues[$size_b]!=""){
  echo '<li>'.$size_arr[$j].'</li>';
 }
else{
  echo '<li><strike  style="">'.$size_arr[$j].'</strike></li>';      
 }
  $j++;
}
}
?>

                </ul>








eg:----<?php
    $_productCollection=$this->getLoadedProductCollection();
    $columnCount = mdlList('column_count');
    $this->setColumnCount($columnCount);
    $_helper = $this->helper('catalog/output');  
   
?>
<?php
$_activeFilters[] = array();
$_filters = Mage::getSingleton('Mage_Catalog_Block_Layer_State')->getActiveFilters();
foreach ($_filters as $_filter):?>
<?php if($_filter->getName()=="Size"){ ?>
<?php $current_size_filter = $this->stripTags($_filter->getLabel()); ?>
<?php } ?>
<?php endforeach; ?>

<?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products row-fluid">


    <?php echo $this->getToolbarHtml() ?>
    <?php // List mode ?>
    <?php if($this->getMode()!='grid'): ?>
    <?php $_iterator = 0; ?>
    <?php $imgSize = 192; ?>
    <ol class="products-list" id="products-list">
    <?php foreach ($_productCollection as $_product): ?>
        <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
            <?php // Product Image ?>
         
           
               <a href="<?php echo $_product->getProductUrl() ?>" class="product-image">
               <?php $_product = Mage::getModel('catalog/product')->load($_product->getId()); ?>
        <img class="firstImg" src="<?php echo Mage::helper('catalog/image')->init($_product, 'image')->constrainOnly(true)->resize(201,201); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
             
                 </a>
             
            <?php // Product description ?>
            <div class="product-shop">
                <div class="f-fix">
                    <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
                    <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
                     <div class="badge">
            <?php if($_product->getData('new')){echo '<span class="new">'. $_product->getAttributeText('new').'</span>';  }?>
            <?php if($_product->getData('sale')){echo '<span class="sale">'. $_product->getAttributeText('sale').'</span>';  }?>
            </div>
                    <?php if($_product->getRatingSummary()): ?>
                    <?php echo $this->getReviewsSummaryHtml($_product) ?>
                    <?php endif; ?>
                    <?php echo $this->getPriceHtml($_product, true) ?>
                   
                    <div class="desc std">
                        <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
                        <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
                    </div>
                    <div class="product_icons">
                    <ul class="add-to-links">
                    <li class="addCart">
                        <?php if($_product->isSaleable()): ?>
                    <?php if ( !($_product->getTypeInstance(true)->hasRequiredOptions($_product) || $_product->isGrouped()) ) { ?>
                        <button rel="tooltip" data-placement="top" type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocationAjax('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                        <span class="cat_loader" id='ajax_loader<?php echo $_product->getId()?>' style='display:none'>
                        <span class="cart_msg">
                        <img alt="" src='<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>'/>
                        </span>
                        </span>
                     
                        <?php } else { ?>
                       
                            <button rel="tooltip" data-placement="top" type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                       
                        <?php }  ?>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
                        </li>
                    <li class="quickBtn">
                        <?php if($_product->isSaleable()): ?>    
                        <a  rel="tooltip" data-placement="top" title="<?php echo $this->__('Quick View')?>" href='<?php echo $this->getUrl('ajax/index/options',array('product_id'=>$_product->getId()));?>' class='fancybox quick_view' id='fancybox<?php echo $_product->getId();?>'>quick view</a>  
                        <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>  
                        </li>
                        <?php if ($this->helper('wishlist')->isAllow()) : ?>
                            <li><a title="<?php echo $this->__('Add to Wishlist')?>" rel="tooltip" data-placement="top" href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
                        <?php endif; ?>
                        <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                            <li class="last"> <a title="<?php echo $this->__('Add to Compare')?>" rel="tooltip" data-placement="top" href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
                        <?php endif; ?>
                    </ul>
                </div>
                </div>
            </div>
        </li>
    <?php endforeach; ?>
    </ol>
    <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>

    <?php else: ?>

    <?php // Grid Mode ?>

    <?php $_collectionSize = $_productCollection->count() ?>
     <?php
   
        $_columnCount = $this->getColumnCount();
       
        if($_columnCount == 4){
            $imgSize = 155;
        }elseif($_columnCount == 3){
            $imgSize = 245;
        }
   
    ?>
    <?php $i=0; foreach ($_productCollection as $_product): ?>
        <?php if ($i++%$_columnCount==0): ?>
        <ul class="products-grid ajaxMdl<?php echo $_columnCount ?>">
        <?php endif ?>

<?php if($_product->isConfigurable()): ?>
 <?php $attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product) ?>
 <?php if(count($attributes)): ?>
<?php foreach($attributes as $att): ?>
 <?php $pAtt=$att->getProductAttribute();
//get the child products
$allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product);
$frontValues =array() ?>
  <?php //echo $pAtt->getFrontendLabel() ?>
  <?php foreach($allProducts as $p): ?>
 <?php if(!$p->isSaleable()) continue; ?>
<?php $out=$p->getAttributeText($pAtt->getName()); ?>
<?php $frontValues[$out]=$out; ?>
  <?php endforeach ?>

<?php endforeach ?>
<?php endif ?>
<?php endif ?>
<?php

if(isset($frontValues)){

if(isset($current_size_filter)){
if($frontValues[$current_size_filter]!=""){
$sold_out_size = 'no';
}else{
   $sold_out_size = 'yes';
}

}
}
//echo $sold_out_size;
?> 
 <?php if($sold_out_size!='yes'){ ?>
            <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?> span4">
            <div class="thumbnail">        
               <div class="image_rotate">
               <a id="prolink" href="<?php echo $_product->getProductUrl() ?>" class="product-image">
               <?php $_product = Mage::getModel('catalog/product')->load($_product->getId()); ?>
               <img class="firstImg" src="<?php echo $this->GetSkinUrl("images/nine_logo.gif"); ?>" onerror="this.onerror=null; this.src='<?php echo $this->GetSkinUrl("images/nine_logo.svg"); ?>'"  data-original="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(true)->resize(255,382); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" style="" />
                  <noscript>
                <img class="firstImg"  src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(true)->resize(255,382)->setQuality(80); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" style="" />
               </noscript>
                 </a>
                </div>
                 <?php if($_product->getRatingSummary()): ?>
                <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                <?php endif; ?>
               
                   
           
            <div class="badge">
            <?php if($_product->getData('new')){echo '<span class="new">'. $_product->getAttributeText('new').'</span>';  }?>
            <?php if($_product->getData('sale')){echo '<span class="sale">'. $_product->getAttributeText('sale').'</span>';  }?>
            </div>    
                <div class="outer_bottom">
             
               <h2 class="product-name">
               <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a><?php echo $current_size_filter; ?> </h2>
               <?php echo $this->getPriceHtml($_product, true) ?>
             
                <div class="product_icons">
                    <ul class="add-to-links">
                    <?php /*?><li class="addCart">
                        <?php //if($_product->isSaleable()): ?>
                    <?php if ( !($_product->getTypeInstance(true)->hasRequiredOptions($_product) || $_product->isGrouped()) ) { ?>
<button rel="tooltip" data-placement="top" type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocationAjax('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<span class="cat_loader" id='ajax_loader<?php echo $_product->getId()?>' style='display:none'>
<span class="cart_msg">
<img alt="" src='<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>'/>
</span>
</span>
                     
                        <?php } else { ?>
                       
                            <button rel="tooltip" data-placement="top" type="button" title="<?php echo $this->__('View Product') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                       
                        <?php }  ?>
                    <?php //else: ?>
                        <!--<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>-->
                    <?php //endif; ?>
                        </li><?php */?>
                    <li class="quickBtn">
                        <?php //if($_product->isSaleable()): ?>    
                        <a rel="tooltip" data-placement="top" title="<?php echo $this->__('Quick View')?>" href='<?php echo $this->getUrl('ajax/index/options',array('product_id'=>$_product->getId()));?>' class='fancybox quick_view' id='fancybox<?php echo $_product->getId();?>'>quick view</a>  
                        <?php //else: ?>
                        <!--<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>-->
                    <?php //endif; ?>  
                        </li>
                        <?php if ($this->helper('wishlist')->isAllow()) : ?>
                            <li><a title="<?php echo $this->__('Add to Wishlist')?>" rel="tooltip" data-placement="top" href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
                        <?php endif; ?>
                        <?php /*?><?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                            <li class="last"> <a title="<?php echo $this->__('Add to Compare')?>" rel="tooltip" data-placement="top" href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
                        <?php endif; ?><?php */?>
                    </ul>
                    <ul class="cat_size">
                <?php
//check if product is a configurable type or not
if ($_product->getData('type_id') == "configurable")
{    

$config = $_product->getTypeInstance(true);

foreach($config->getConfigurableAttributesAsArray($_product) as $attributes)

$s=0;
        //print_r($attributes);
if ($attributes["label"] != "") { 
 
foreach($attributes["values"] as $values)
{
$size_arr[$s] = $values["label"];
$s++;
}

}
}

?>

<?php } 
$j=0;
//echo $qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
//if($qtyStock>0){
if($_product->isSaleable() && $_product->getData('type_id') == "configurable") {
foreach ($_product->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) {
$stock = round(Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple)->getQty());
$size_b = $size_arr[$j];
if($frontValues[$size_b]!=""){
  echo '<li>'.$size_arr[$j].'</li>';
 } 
else{
  echo '<li><strike  style="">'.$size_arr[$j].'</strike></li>';       
 } 
  $j++;
}
}
?>

                </ul>
             
                </div>
               
                </div>
                  <?php if(!$_product->isSaleable()) { ?>
                <div class="sold_ot"><img src="<?php echo $this->getSkinUrl('images/Sold-Out.png')?>" /></div>
                <?php } ?>
                </div>
            </li>
<?php }else{
--$i;
}
?>

        <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
        </ul>
        <?php endif ?>
        <?php endforeach ?>
        <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
    <?php endif; ?>

 
</div>
<?php endif; ?>
 <div class="toolbar-bottom" >
        <?php //echo $this->getToolbarHtml() ?>
    </div>
<style>
    /* to prevent flickering */
    .lazy-hidden {
        opacity: 0;
    }
</style>
<script type="text/javascript">
    jQuery(window).scroll(function(){
        jQuery("[rel=tooltip]").tooltip();
    });
    jQuery(document).ready(function() {
            /*jQuery(".image_rotate img").lazyLoad({
                effect : "fadeIn",
                threshold : 1000
            });*/
            jQuery(".image_rotate img").lazyLoadXT({
                edgeY:  200,
                srcAttr: 'data-original'
            });
            jQuery.lazyLoadXT.onload.addClass = 'animated fadeIn';
            jQuery.lazyLoadXT.onload.removeClass = 'lazy-hidden';
           
            /* $.lazyLoadXT.onload = function() {
                    var $el = $(this);
                    $el
                        .removeClass('lazy-hidden')
                        .addClass('animated ' + $el.attr('data-effect'));
                };*/
    });
</script>

Comments

Popular posts from this blog

Parsing Domain Name From URL In PHP

To get Domain name from the url, we can use parse_url() php function. This would filter the domain name from the given url. $domain = str_ireplace ( 'www.' , '' , parse_url ( $url , PHP_URL_HOST )); This would return the google.com for both http://google.com and http://www.google.com

get directory paths, get Base URLs, get URLs in static block, get secure URL in Magento

1) Get Directory paths  Mage::getBaseDir()  //output : /var/www/html/magento Mage::getBaseDir('app')  //output : /var/www/html/magento/app Mage::getBaseDir('media') //output : /var/www/html/magento/media Mage::getBaseDir(‘design’) => Get design directory path Mage::getBaseDir(‘code’) => Gives code directory file path Mage::getBaseDir(‘lib’) => Gives lib directory file path Mage::getBaseDir(‘skin’) => Gives skin directory file path Mage::getBaseDir(‘var’) => Gives var directory file path Mage::getBaseDir(‘cache’) => Gives cache directory file path Mage::getBaseDir(‘log’) => Gives log directory file path       2) Get Base URL  Mage::getBaseUrl() => Get base url path e.g. http://yourwebsite.com/  Mage::getBaseUrl('media') => Get MEDIA folder path e.g. http://yourwebsite.com/media/  Mage::getBaseUrl('js') => Get JS folder path e.g. http://yourwebsite.com/js/  Mage::getBaseUrl('skin') => Get...

Upgrade from Magento 1.7.0.2 to 1.9.0.1

Upgrade Roadmap for 1.9.0.1 from 1.7 1) take a backup of current database and current 1.7 code. 2) download latest magento from the  http://www.magentocommerce.com/download 3) remove all folders and files from your 1.7 code (but you should  have backup somewhere) and place all folders and files from the 1.9. 4) now from your 1.7 merge your following custom folders into the 1.9 - Community app/code/community - Local app/code/local - Media - your theme or package (app/design/frontend/default/<ur theme> or  app/design/frontend/<your package>) - custom folders from Skin (both for adminhtml and frontend). - copy your custom xml files from app/etc/modules/ to current  app/etc/modules/ - any custom admin theme folder  from adminhtml/default/yourtheme. - copy your custom folders from adminhtml/default/default/ (1.7)  to adminhtml/default/default/ (1.9). - custom js files if any from app/js/. 5) now go to app/e...