Magento - Open Page as LightBox Instead in New Window or Tab

Magento - Open Page as LightBox Instead in New Window or Tab

August 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - Open Page as LightBox Instead in New Window or Tab

Magento Lightbox Popups for Product Pages

As a senior developer who specializes in e-commerce platforms like Magento, I understand your needs when it comes to enhancing user experience through interactive features such as lightbox popups.

The Current Setup and Your Requirements

You’ve discovered an interesting design element on the demo page you provided - the transparent hover windows with product details. However, what you’re aiming for is a seamless transition from these hovered elements directly into a popup lightbox, containing the full product information without requiring a new page load or window.

Understanding the Lightbox Concept in Magento

In Magento, implementing a lightbox functionality requires careful integration of JavaScript libraries and proper configuration of your theme. The most popular choice for creating lightboxes is the jQuery-based plugin called Magnific Popup or Colorbox.

Step-by-Step Approach to Integrating a Lightbox

  1. Choose Your Library: For this tutorial, let’s use Magnific Popup as it provides robust cross-browser support and clean code structure.

  2. Installation: Download the library from their official website (https://dimsemenov.com/magnific-popup/), extract the files, and upload them to your theme directory, typically under app\design\frontend\{vendor}\{theme}\web. You’ll need the CSS file (magnific-popup.css) in your theme’s CSS folder and the JavaScript file (jquery.magnific-popup.js) in the JavaScript folder.

  3. Configure Your Theme: In your theme’s config.xml file, add the following XML code under <config> tag to load the library:

<static>
  <remove name="require-js" />
  <requires>
    <js file="js/jquery.magnific-popup.js"/>
    <css src="css/magnific-popup.css"></css>
  </requires>
</static>
  1. Implementing the Lightbox: For the “PREGLED” button in your offer boxes, you’ll need to add a Magnific Popup trigger.
<a href="<?php echo $product->getProductUrl() ?>" class="popup-product-js">PREGLED</a>
  1. JavaScript Configuration: In your theme’s JavaScript file (usually js/script.js), include the following code:
jQuery(document).ready(function($) {
    $('.popup-product-js').magnificPopup({
        type: 'ajax',
        midClick: true,
        ajax: {
            settings: {
                method: 'GET',
                dataType: 'html'
            }
        },
        callbacks: {
            parseAjax: function(mfpResponse) {
                return {
                    markup: mfpResponse.data
                };
            }
        }
    });
});

What Else You Should Know

The code above assumes you’re using Magento’s default product view template (catalog/product/view.phtml). If your theme customizes this layout, you’ll need to adjust the popup configuration accordingly.

Remember, for a clean and professional look, make sure your popup matches your website’s design and branding. Use CSS to style the Magnific Popup elements as per your theme.

Addressing Your Layout Concerns

To make the popup more appealing:

  1. Add a Background: Consider adding a semi-transparent background color or image behind the content using CSS.
.mfp-wrap .mfp-container {
  background-color: rgba(0,0,0,0.8);
}
  1. Style Elements: Use CSS to style the popup elements like headings, buttons, and images to match your theme.

  2. Animation Tweaks: Experiment with the Magnific Popup options for transitions and effects in the JavaScript configuration file.

Conclusion

Implementing a lightbox popup in Magento is a powerful way to improve user engagement and reduce page load time. By following this guide, you should now be able to open product pages as interactive popups instead of new windows or tabs.

Remember, with great power comes great responsibility - ensure your popups are responsive and provide an easy way for users to close them. If you need further assistance or want to explore more advanced Magento features, feel free to reach out to our team at Laravel Company.

Happy coding!

Catalog Database API Extensions

Our network