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

Trick to get Vaccine slot in India

  This will allow users to find available slots for COVID-19 vaccines in the centers around them. Steps: You should see the Vaccine Finder option. Alternatively, Android mobile phone users can tap on ‘All’ –> followed by the COVID-19 Vaccination Appointment banner Enter your pincode / district and choose between 18+ and 45+ age groups Select on Check Availability to proceed All available slots details will appear on your screen If there are no available slots, you can click on ‘Notify me when slots are available’ option to get alerts for open slots

Is covid virus really airborne?

  If airborne transmission is a significant factor in the pandemic, especially in crowded spaces with poor ventilation, the consequences for containment will be significant. How did the experts reach this conclusion? Reviewing existing research, the six experts from the UK, US and Canada identified 10 streams of evidence that collectively support the hypothesis that SARS-CoV-2 primarily transmits through the airborne route. 1. Super-spreading events account for substantial SARS-CoV-2 transmission. Indeed, the authors wrote, such events may be the  pandemic ’s primary drivers. Detailed analyses of human behaviours and other variables in concerts, cruise ships etc have shown patterns “consistent with airborne spread of SARS-CoV-2 that cannot be adequately explained by droplets or fomites”, they wrote. 2. Long-range transmission of SARS-CoV-2 between people in adjacent rooms has been documented in quarantine hotels, but never in each other’s presence. 3. Asymptomatic or pre-sympt...