How can I include custom jquery slider for related products Magento 1.7.0.2

How can I include custom jquery slider for related products Magento 1.7.0.2

September 4, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How can I include custom jquery slider for related products Magento 1.7.0.2

Building a custom jQuery slider to display related products on your Magento product page can greatly enhance the user experience by allowing customers to quickly browse similar items with ease. In this guide, I’ll walk you through the process of integrating a horizontal jQuery slider into your view.phtml file for Magento 1.7.0.2.

First, let’s review how to fetch related products using native Magento functionality:

<?php $related_prods = $_product->getRelatedProductIds(); ?>
<?php foreach($related_prods as $related): ?>
    <?php $_rel = Mage::getModel('catalog/product')->load($related); ?>
    <?php echo $_rel->getName(); ?>
    <img src="<?php echo $_rel->getImageUrl(); ?>"/>
<?php endforeach; ?>

This code snippet retrieves the IDs of related products and iterates through them, loading each product object using Mage::getModel('catalog/product'). It then outputs the product name and image URL for display.

Including a Horizontal jQuery Slider

To include a horizontal jQuery slider in your view.phtml file, you’ll first need to load the necessary JavaScript libraries. For this example, we’ll use the popular Flexslider plugin:

  1. Include the CSS stylesheet in your theme’s layout files:
<head>
    <!-- ... -->
    <link rel="stylesheet" href="https://laravelcompany.com/your-slider-styles.css">
</head>
  1. Load the jQuery library and Flexslider JavaScript file:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://laravelcompany.com/flexslider.js"></script>
  1. Add the necessary markup for the slider in your view.phtml file:
<div class="flexslider">
    <ul class="slides">
        <?php foreach($related_prods as $related): ?>
            <?php $_rel = Mage::getModel('catalog/product')->load($related); ?>
            <li>
                <img src="<?php echo $_rel->getImageUrl(); ?>" />
                <h2><?php echo $_rel->getName(); ?></h2>
            </li>
        <?php endforeach; ?>
    </ul>
</div>
  1. Initialize the Flexslider using JavaScript:
$(window).load(function() {
  $('.flexslider').flexslider({
    animation: "slide",
    controlNav: false,
    directionNav: true,
    slideshowSpeed: 5000,
    animationLoop: true,
    itemWidth: 210,
    itemMargin: 5
  });
});

This code initializes the Flexslider plugin with various configuration options, such as slide duration, animation type, and item width.

Conclusion

Integrating a custom jQuery slider to display related products in Magento 1.7.0.2 is an effective way to enhance your website’s user experience. By following this guide, you can easily create a horizontal product slider that showcases relevant items alongside the main product details.

Remember to customize the Flexslider CSS stylesheet (https://laravelcompany.com/your-slider-styles.css) to match your theme and adjust the configuration options as needed.

With these steps, you should now have a working jQuery slider for related products in your Magento store. If you encounter any issues or require further assistance with customizing your Magento themes, feel free to explore more tutorials and resources at Laravel Company.

Magento 1 Catalog Database Extensions

Our network