Skip to content

Commerce Foundations is our pre-built Craft Commerce store. See what it includes

Craft CMS plugins

Klaviyo Connect

A Craft CMS plugin for Klaviyo.

Product Feed

In Klaviyo, product feeds are added via Catalog Sources. This view is hidden for custom API plugins like this one, but still accessible and usable here: https://www.klaviyo.com/catalog/sources. Once you’ve created your JSON feed, add it to a new Catalog Source to make the products within it available to your Klaviyo emails. Confirm your product feed is working on the Catalog page.

Download Klaviyo’s documentation for Custom Catalogs

JSON Feed in Twig#

You can use Twig to generate a JSON feed. Create a template like the following example and make sure it is publicly accessible:

{% if craft.app.plugins.isPluginInstalled('klaviyo-connect-plus') %}
    {% set productImageField = craft.app.getPlugins().getPlugin('klaviyo-connect-plus').getSettings().productImageField %}
{% endif %}

{% set products = craft.products().hasVariant({ hasStock: true }).with(productImageField is defined ? [productImageField] : []).all() %}

{% set feed = [] %}

{% for product in products %}
    {% set variant = product.defaultVariant %}
    {% set feedProduct = {
        'SKU'        : variant.sku,
        'ProductName': product.title,
        'ProductType': product.type,
        'ProductURL' : variant.url,
        'ItemPrice'  : variant.price,
        'ProductID'  : product.id,
    } %}

    {% if productImageField is defined and product[productImageField]|length > 0 %}
        {% set feedProduct = feedProduct|merge({
            'ProductImage': product[productImageField][0].url,
        }) %}
    {% endif %}

    {% set feed = feed|merge([feedProduct]) %}
{% endfor %}

{{ feed|json_encode }}

We can take it from here.

We take on the Craft and Craft Commerce sites you built, so you can get back to building. Introduce a client who signs a management contract and you get a $3,000 partnership fee.

How the Dev Partnership Program works
See if we’re a fit