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

Magento Form Validators

Magento Javascript Validation Classes There are many more validation classes you can assign and I list them here as a reference. For more information on this please use Google, experiment with the code or contact me via my email or the contact form. validate-select Please select an option required-entry This is a required field validate-number Please enter a valid number in this field validate-digits Please use numbers only in this field. please avoid spaces or other characters such as dots or commas validate-alpha Please use letters only (a-z or A-Z) in this field. validate-code Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter. validate-alphanum Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed validate-street Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field validate-phoneStrict

How to create Guest Wishlist For Magento

Add to wishlist without customer login Add three tables CREATE TABLE `wishlist` ( `wishlist_id` INT(11) NOT NULL AUTO_INCREMENT, `customer_id` INT(11) NULL DEFAULT NULL, `shared` INT(11) NULL DEFAULT NULL, `sharing_code` VARCHAR(50) NULL DEFAULT NULL, `updated_at` TIMESTAMP NULL DEFAULT NULL, `cookie` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`wishlist_id`) ) COLLATE='latin1_swedish_ci' ENGINE=InnoDB AUTO_INCREMENT=0 ; CREATE TABLE `wishlist_item` ( `wishlist_item_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Wishlist item ID', `wishlist_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Wishlist ID', `product_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Product ID', `store_id` SMALLINT(5) UNSIGNED NULL DEFAULT NULL COMMENT 'Store ID', `added_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Add date and time', `description` TEXT NULL COMMENT '