Guide

How to add a 3D product configurator to Magento and Adobe Commerce

, imagine.io ·

The imagine.io Configurator Platform works on Magento Open Source and Adobe Commerce through a sharing link. Paste one iframe tag into the product page with Page Builder's HTML Code element, and add your store's domain to the link's allowed domains in the imagine.io dashboard. The configurator loads with its own customisation options and live price, or with the panel hidden and your own buttons driving it. No Marketplace extension; the cart line takes a small module of your own, shown below. On a headless or PWA storefront built in React, mount the SDK instead: the React guide.

1 THE LINKimagine.io dashboardScenes › Configurable Systems› Sharing Links: add your domain,then Copy embed code2 PASTE ITMagentoCatalog › Products › editContent › HTML Code elementpaste the iframe, save3 LIVEYour product page3D view, customisation options,live priceadd to cart through the bridgethe link carries its own catalog and theme; the page only frames it 1 THE LINKimagine.io dashboardScenes › Configurable Systems› Sharing Links: add your domain,then Copy embed code2 PASTE ITMagentoCatalog › Products › editContent › HTML Code elementpaste the iframe, save3 LIVEYour product page3D view, customisation options,live priceadd to cart through the bridgethe link carries its own catalog and theme;the page only frames it
Where the embed goes: the link is made in the dashboard, pasted into the Magento editor, and the configurator renders inside the page.
This guide uses the embed route. One iframe, a sharing link, and the bridge for the cart. Your own buttons are already covered: hide the configurator's panel and drive it from the page through the bridge (step 5 below). Want to change the configurator itself, the parts inside the frame? Build it with the SDK, host that page, and embed it with the same iframe: the bridge activates on any page that mounts the SDK inside an iframe, so everything below about the cart works unchanged. All three routes: which route fits which site.

The embed code

One element. The configurator boots, loads its catalog and renders itself, with its customisation options and live price. Replace lk_YOUR_LINK with your sharing link.

<iframe
  id="configurator"
  title="Product configurator"
  src="https://configurator.imagine.io/lk_YOUR_LINK"
  style="width:100%; height:640px; border:0; display:block"
  allow="xr-spatial-tracking; fullscreen; clipboard-write"
  referrerpolicy="strict-origin-when-cross-origin"
  loading="lazy"></iframe>

Step by step

  1. Create the sharing link and allow your domain

    In the imagine.io dashboard open Scenes › Configurable Systems, pick the system, and on its Sharing Links tab create a link. Give it a name for where it will live, choose a theme or leave the default, and under Allowed domains add every domain the page will be served from. Leave the list empty while you test locally, and fill it in before you go live: a link embedded on a domain that is not listed shows a “not authorized” card instead of the configurator.

    Copy embed code on the row gives you the iframe below with the link filled in.

    The Sharing Links tab of a system, with one link showing its name, theme and allowed domains
    Scenes › Configurable Systems › Sharing Links. One link per place you use it; the allowed domains are set here.
  2. Paste it into the product page

    In the Magento admin open Catalog › Products and edit the product. Expand Content, press Edit with Page Builder, drag an HTML Code element (under Elements) to where the configurator should appear, and paste the iframe. Save the product. Magento may warn that the content holds restricted HTML elements; by default it still saves. Without Page Builder, press Show / Hide Editor on the description and paste the iframe into the plain HTML.

    For every product of a line, a developer can instead add a block to catalog_product_view.xml in your theme whose template prints the iframe, with each product's sharing link stored in a product attribute, so no product content carries code. Adobe's guide to the element: HTML Code.

  3. Allow the frame in the store's Content Security Policy

    Magento 2.3.5 and later ship a Content Security Policy module. If the browser console reports a frame-src violation for configurator.imagine.io, allow it in a csp_whitelist.xml in your theme's or module's etc folder:

    <?xml version="1.0"?>
    <!-- etc/csp_whitelist.xml: let the store's pages frame the configurator -->
    <csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
      <policies>
        <policy id="frame-src">
          <values>
            <value id="imagine-configurator" type="host">https://configurator.imagine.io</value>
          </values>
        </policy>
      </policies>
    </csp_whitelist>
  4. Size it for the page

    The iframe takes the width of its container. Give it a height that fits the product layout, 640px is a good start, or 80vh for a full-page experience. On phones the configurator lays itself out for the narrow width.

  5. Decide who owns the customisation options

    Keep the configurator's panel, or hide it with ?hide=sidebar on the link and drive the scene from your own swatches through the postMessage bridge. The 3D view stays.

    https://configurator.imagine.io/lk_YOUR_LINK?hide=sidebar

    With the panel hidden, your page sends the choices in. Wait for the frame to say it is ready, read the option sets to build your own swatches from, then select by name or by id. The ten-line callConfigurator helper is the one from the cart section below.

    const iframe = document.getElementById('configurator');
    
    window.addEventListener('message', (e) => {
      if (e.data?.type === 'configurator:ready') start();          // the frame is listening
    });
    
    async function start() {
      // Every option set and option, to build your own swatches from
      const sets = await callConfigurator(iframe, 'getOptionSets');
    
      // Your swatch -> the configurator. By name, or by id when your CMS stores ids
      await callConfigurator(iframe, 'selectOption', { optionSet: 'Fabric', option: 'Cognac' });
      await callConfigurator(iframe, 'selectOption', { optionSetId: 41, optionId: 118 });
    
      // Hide or show parts of the configurator's interface after boot
      await callConfigurator(iframe, 'hideUI', { regions: ['sidebar'] });
    }

    What you can pass and what comes back: the URL parameters (hide, gui, theme, project, config), the full protocol, every command with its payload and its real reply (select options, read the quote and the state, camera, interface regions, undo and redo), the events the frame sends out, and the helper. One thing to know: a command the frame accepts can still be refused by a rule a moment later, which arrives as an evaluate.rejected event, so roll a cart line back on that event, not on the command's reply.

  6. Add every domain you serve from

    Add the live domain, each store view's domain if they differ, and any staging domain to the link's allowed domains. The check reads the referrer, so keep the iframe's referrerpolicy at strict-origin-when-cross-origin or looser.

  7. Test on the store

    Flush the cache under System › Cache Management, open the product on the live domain, change a few options and watch the price. Then wire the cart below.

Hand the configuration to your cart

The bridge gives the page the itemised quote, a thumbnail and a snapshot of the build. To get them onto the Magento cart line: the JavaScript below posts them, with the page's form key, to a controller in a small module of your own, which adds the product with the configuration attached as additional options. Magento shows those on the cart, the mini cart and the checkout, and an observer copies them onto the order. Put the button and the scripts in your theme's product page template, next to the block that prints the iframe, rather than in product content.

<button id="add-to-cart" disabled>Add to cart</button>
// Ten lines you write once: posts a command into the iframe and resolves with its reply.
function callConfigurator(iframe, action, payload) {
  return new Promise((resolve, reject) => {
    const requestId = 'req-' + Math.random().toString(36).slice(2);
    const onReply = (e) => {
      const m = e.data;
      if (m?.type !== 'configurator:response' || m.requestId !== requestId) return;
      window.removeEventListener('message', onReply);
      m.success ? resolve(m.data) : reject(new Error(m.error));
    };
    window.addEventListener('message', onReply);
    iframe.contentWindow.postMessage({ action, payload, requestId }, '*');
  });
}
const iframe = document.getElementById('configurator');
const add = document.getElementById('add-to-cart');

window.addEventListener('message', (e) => {
  const m = e.data;
  if (m?.type === 'configurator:ready') add.disabled = false;
  // The price follows every change the shopper makes. No polling.
  if (m?.type === 'configurator:event' && m.event === 'price.changed') {
    add.textContent = `Add to cart: ${m.data.currency} ${m.data.grandTotal}`;
  }
});

add.onclick = async () => {
  const quote      = await callConfigurator(iframe, 'getQuote');          // itemised, priced by the engine
  const { dataUrl } = await callConfigurator(iframe, 'getScreenshot');    // thumbnail for the cart
  const snapshot   = await callConfigurator(iframe, 'getConfiguration');  // reopen the exact build later
  const body = new FormData();
  body.append('form_key', document.querySelector('input[name="form_key"]').value);
  body.append('product_id', MAGENTO_PRODUCT_ID);   // the product that carries the configured item
  body.append('quote', JSON.stringify(quote));
  body.append('snapshot', JSON.stringify(snapshot));
  await fetch('/imagineconfig/cart/add', { method: 'POST', body });
  window.location.href = '/checkout/cart/';         // dataUrl: show it on your page, or upload it to your media storage
};

MAGENTO_PRODUCT_ID is the product's id: the number after /id/ in the address bar while you edit it in the admin. The module has six small files. Here it is named Imagine_Configurator and lives in app/code/Imagine/Configurator; rename it to your vendor.

<?php
// registration.php: tell Magento the module exists
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Imagine_Configurator', __DIR__);
<!-- etc/module.xml: the module's name, loaded after Magento_Checkout -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
  <module name="Imagine_Configurator">
    <sequence><module name="Magento_Checkout"/></sequence>
  </module>
</config>
<!-- etc/frontend/routes.xml: the URL /imagineconfig/... -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
  <router id="standard">
    <route id="imagineconfig" frontName="imagineconfig">
      <module name="Imagine_Configurator"/>
    </route>
  </router>
</config>
<?php
// Controller/Cart/Add.php: add the product with the configuration attached
namespace Imagine\Configurator\Controller\Cart;

use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Data\Form\FormKey\Validator;
use Magento\Framework\DataObject;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Store\Model\StoreManagerInterface;

class Add implements HttpPostActionInterface
{
    public function __construct(
        private RequestInterface $request,
        private Validator $formKey,
        private Session $session,
        private ProductRepositoryInterface $products,
        private CartRepositoryInterface $carts,
        private JsonFactory $json,
        private Json $serializer,
        private StoreManagerInterface $stores
    ) {}

    public function execute()
    {
        $result = $this->json->create();
        if (!$this->formKey->validate($this->request)) {
            return $result->setHttpResponseCode(400)->setData(['error' => 'Invalid form key']);
        }
        $quote = $this->serializer->unserialize($this->request->getParam('quote'));
        $storeId = (int) $this->stores->getStore()->getId();
        $product = $this->products->getById((int) $this->request->getParam('product_id'), false, $storeId, true);

        // One row per placed product with its chosen options, shown on the cart and the checkout;
        // a different configuration makes a separate line
        $rows = [['label' => 'Configuration', 'value' => $quote['system']['name']]];
        foreach ($quote['lines'] as $line) {
            $rows[] = ['label' => $line['name'], 'value' => implode(', ', array_column($line['selections'], 'optionName'))];
        }
        $product->addCustomOption('additional_options', $this->serializer->serialize($rows));
        $product->addCustomOption('imagine_snapshot', $this->request->getParam('snapshot'));

        $cart = $this->session->getQuote();
        $item = $cart->addProduct($product, new DataObject(['qty' => 1]));
        if (is_string($item)) {
            return $result->setHttpResponseCode(400)->setData(['error' => $item]);
        }
        $this->carts->save($cart->collectTotals());
        $this->session->setQuoteId($cart->getId());
        return $result->setData(['ok' => true]);
    }
}
<!-- etc/events.xml: copy the configuration onto the order line -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
  <event name="sales_model_service_quote_submit_before">
    <observer name="imagine_configuration_to_order" instance="Imagine\Configurator\Observer\CopyToOrder"/>
  </event>
</config>

<?php
// Observer/CopyToOrder.php: move the configuration from the cart line to the order line
namespace Imagine\Configurator\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Serialize\Serializer\Json;

class CopyToOrder implements ObserverInterface
{
    public function __construct(private Json $serializer) {}

    public function execute(Observer $observer)
    {
        $order = $observer->getEvent()->getOrder();
        foreach ($observer->getEvent()->getQuote()->getAllVisibleItems() as $quoteItem) {
            $option = $quoteItem->getOptionByCode('additional_options');
            if (!$option) continue;
            $orderItem = $order->getItemByQuoteItemId($quoteItem->getId());
            $options = $orderItem->getProductOptions();
            $options['additional_options'] = $this->serializer->unserialize($option->getValue());
            $options['imagine_snapshot'] = $quoteItem->getOptionByCode('imagine_snapshot')?->getValue();
            $orderItem->setProductOptions($options);
        }
    }
}

Enable it with bin/magento module:enable Imagine_Configurator and bin/magento setup:upgrade.

What arrives in the cart: one line with the product's own SKU and rows under it: Configuration with the system's name, then one row per placed product with its chosen options, for example Corner unit: Cognac leather, Oak legs. The order then shows the configuration in the admin and in the customer's account, and the snapshot reopens the exact build. On a Hyvä theme, read the form key with hyva.getFormKey().

The price the engine returns is in quote.totals.grandTotal. Magento charges the product's own price unless you set a custom price on the cart item. That price arrived from the browser, so check it on your server before you charge it, or keep the product's price and treat the quote as the order's specification. The bridge chapter documents every field of the quote.

Frequently asked questions

Which 3D configurator works with Magento or Adobe Commerce?

The imagine.io Configurator Platform. It runs on Magento Open Source and Adobe Commerce as a sharing link embedded with one iframe on the product page, through Page Builder's HTML Code element or a layout block, and a small module of your own puts the configuration on the cart line and the order. Headless and PWA storefronts built in React can mount the SDK instead. Rules, constraints and pricing run on imagine.io's servers, so nothing heavy is installed in the store.

Do I need an extension from the Magento Marketplace?

No. The embed is one iframe in the product content, and the cart hand-off is a small module of your own: a route, a controller and an observer, shown above. Nothing is installed from the Marketplace.

Does it work on Adobe Commerce, Adobe Commerce Cloud and Hyvä?

Yes. Adobe Commerce and Adobe Commerce Cloud run the same Magento code, so the iframe and the module are the same; on Cloud the module is deployed through your project's git repository. On a Hyvä theme the iframe is the same and the form key comes from hyva.getFormKey().

Can Magento charge the engine's price?

Yes, by setting a custom price on the cart item from quote.totals.grandTotal. Because that number comes from the shopper's browser, check it on your server before you charge it. Without a custom price Magento charges the product's own price, and the configuration still travels with the order line.

My site has a Content-Security-Policy. What does it need?

Allow the configurator origin in frame-src, for example frame-src https://configurator.imagine.io. The configurator host permits framing by the domains in the link's allowed domains, so add your site there too.

Can I use my own swatches instead of the configurator's customisation options on Magento?

Yes. Add ?hide=sidebar to the link so the panel disappears, then call selectOption from your page through the postMessage bridge. getOptionSets returns every option set and option to build your buttons from. The SDK docs cover each command.

Troubleshooting

The page shows a “not authorized” card instead of the configurator.

The page's domain is not in the link's Allowed domains. Add it in Scenes › Configurable Systems › Sharing Links, including any preview or staging domain you test on. The check reads the referrer, so the iframe must not set referrerpolicy to no-referrer.

The configurator is blank, or the events arrive but every command times out.

Two usual causes. The page is opened from the file system rather than a web server: a file:// page has no origin the browser will deliver replies to. Or the iframe has a sandbox attribute that strips allow-scripts or allow-same-origin. Remove the sandbox attribute and serve the page over http.

Fullscreen or the Copy button does not work inside the embed.

The iframe needs allow="xr-spatial-tracking; fullscreen; clipboard-write". Without fullscreen the browser blocks the fullscreen toggle. Without clipboard-write in the iframe’s allow attribute, the browser blocks copying inside the configurator.

A licence notice appears on the real site but not in testing.

The free plan is for non-commercial evaluation with the imagine.io watermark. Running on your own domain and storefront is part of a paid plan; the plans are in the dashboard under Settings › Billing.

Other platforms

SDK documentation · Admin guide