jcadima
11/17/2016 - 2:17 PM

PHP Carousel (magento)

PHP Carousel (magento)


Reference: http://bootsnipp.com/snippets/featured/carousel-product-cart-slider

1) Create a new phtml file:
/app/design/frontend/em0140/default/template/featuredcustom.phtml

2) Create a New Category ie: Featured

3) paste into cms page
{{block type="core/template" template="featuredcustom/featuredcustom.phtml"}}

4) paste the following into featuredcustom.phtml

<?php
// 80 will be the ID of the category name: Featured
$products = Mage::getModel('catalog/category')->load(80); // 72: featured products category ID
// get all products
$productslist = $products->getProductCollection()->addAttributeToSelect('*');



<!--  CONTROLS  -->
<div class="row">
    <div class="col-md-24">
        <!-- Controls -->
        <div class="controls pull-right hidden-xs">
            <a class="left fa fa-chevron-left btn" href="#carousel-example"  data-slide="prev"></a>
            <a class="right fa fa-chevron-right btn" href="#carousel-example" data-slide="next"></a>
        </div>
    </div>
</div>


<!--  CAROUSEL  -->    
<div id="carousel-example" class="carousel slide hidden-xs" data-ride="carousel" data-interval="900000">

    <div class="carousel-inner">
        <div class="item active">
            <div class="row">
      

<?php
$active = '';
$counter = 0;               
    foreach($productslist as $product) :   ?>
   
   	<?php // break div at 4 items 
   		if ( $counter % 4 == 0 && $counter != 0 ) :  ?>
   			</div> <!-- row -->
   		</div>  <!--  item active  -->
        <div class="item">
            <div class="row">					  
		<?php endif; ?>		   
		              
                <div class="col-sm-6">
                    <div class="col-item">
                        <div class="photo">
                            <a href="<?php echo $product->getProductUrl() ; ?>" ><img src="<?php echo  Mage::helper('catalog/image')->init($product, 'thumbnail') ; ?>" class="img-responsive" alt="a" /></a>
                        </div>
                        <div class="info">
                            <div class="separator clear-left">
                                <p class="btn-add">
                                    <a href="<?php echo $product->getProductUrl() ; ?>" class="hidden-sm blue"><?php echo  $product->getName() ; ?></a></p>
                            </div>
							<div class="clearfix" style="clear:both;"></div>
                		</div>
                    </div>
                </div>
    
   <?php $counter++;  endforeach ; echo '</div></div>'; ?>           

    </div> <!-- carousel-inner -->
</div>   <!-- #carousel-example  -->