Using in Your Store

Setting up a Data Feed in Smartweb / HostedShop

Sync data to with a Prisindeks feed

  1. In the SmartWeb Admin, go to Kontrolpanel->Prisindeks 

  2. Create a new Prisindex by clicking Opret Eget Prisindeks in the top right corner.

  3. Give it the name Clerk.

  4. Use the following code to create the Data Feed. This will generate a link with the product feed, which can be used in the HTML Annotations importer at

Insert in Feed Start Template

{* Image size *}
{$imageWidth = 282}
{$imageHeight = 282}

{* Thumbnail size *}
{$thumbnailWidth = 60}
{$thumbnailHeight = 60}

{* Is price including vat - set via query price_including_vat=true/false - default: true *}
{$priceIncludingVat = true}

{if isset($smarty.get.price_including_vat)}
    {$priceIncludingVat = ($smarty.get.price_including_vat eq "true")}

{* Include out of stock products - set via query include_out_of_stock=true/false - default: false *}
{$includeOutOfStock = (isset($smarty.get.include_out_of_stock) && $smarty.get.include_out_of_stock eq "true")}

{* Instantiate controllers *}
{controller assign=productController type=product}
{controller assign=brandController type=user}
{controller assign=variantController type=productVariant}
{controller assign=priceController type=productPrice}
{controller assign=cartController type=cart}

{$productPageLink = PageController::link($page.productPageId)}

{* Set date variable (now + 1 month in Y-m-d format) *}
{assign date {date('Y-m-d', strtotime("+1 months", strtotime("NOW")))}}

{collection controller=productCategory assign=categories}

{$productLink = {page id=$page.productPageId print=Link}}

{function name=renderCategories}
    {foreach $items->getData() as $item}
        {collection controller=productCategory assign=subCategories parentId=$item->Id}

        <span class="clerk-category-info"
            data-subcategories="[{if $subCategories}{foreach $subCategories->getData() as $category}{$category->Id}{if not $category@last}, {/if}{/foreach}{/if}]">

        {call name=renderCategories items=$subCategories}

{call renderCategories items=$categories}

Insert in Feed Item Template

{* Determine if product is sold out *}
{$soldout = ($product->Soldout and !$product->AllowOutOfStockPurchase)}

{if !$soldout || $includeOutOfStock}
    {* Load variants of the product *}
    {collection assign=variants controller=$variantController productId=$product->Id variantId=$product->VariantIds}
    {assign variants $variants->getData()}
    {* Fetch the brand of the product *}
    {entity assign=brand controller=$brandController id=$product->ProducerId}
    {* Fetch the variant types of the product *}
    {collection assign=variantTypes controller=$variantTypeController productId=$product->Id}
    {* Fetch the picture of the product *}
    {*assign productPicture {picturePath productId=$product->Id}*}
    {entity assign=image controller=files type=shop productId=$product->Id}

    {if $image}
        {$crop = "fill"}

        {if !empty($template.settings.DESIGN_IMAGE_BACKGROUND_COLOR)}
            {$crop = $template.settings.DESIGN_IMAGE_BACKGROUND_COLOR}

        {$thumbnailPath = $image->thumbnail($thumbnailWidth, $thumbnailHeight, $crop)}
        {$imagePath = $image->thumbnail($imageWidth, $imageHeight, $crop)}
        {placeholdImage assign=placeholder width=$thumbnailWidth height=$thumbnailHeight background=$template.settings.DESIGN_IMAGE_BACKGROUND_COLOR color=$template.settings.FONT_COLOR_PRIMARY text=$text.IMAGE_PLACEHOLDER_TEXT}

        {$thumbnailPath = $placeholder->getRelativeFile()}

        {placeholdImage assign=placeholder width=$imageWidth height=$imageHeight background=$template.settings.DESIGN_IMAGE_BACKGROUND_COLOR color=$template.settings.FONT_COLOR_PRIMARY text=$text.IMAGE_PLACEHOLDER_TEXT}

        {$imagePath = $placeholder->getRelativeFile()}
    {* Fetch the short description of the product *}
    {assign productDescription $productController->getDescriptionShort($product->Id)}
    {* If blank, fetch the list description of the product *}
    {if empty($productDescription)}
        {assign productDescription $productController->getDescriptionList($product->Id)}
    {* If blank, fetch the long description of the product *}
    {if empty($productDescription)}
        {assign productDescription $productController->getDescription($product->Id)}
    {* Trim the description to a max length of 5000 characters *}
    {$productDescription = $productDescription|strip_tags|unescape:"htmlall"|trimTo:5000}
    {* Fetch the category path of the product *}
    {assign categoryPathTitle {categoryTitlePath product=$product separator=" > "}}
    {* Convert product age from seconds to days *}
    {$ageInDays = ($product->Age / 60 / 60 / 24)|string_format:"%.1f"}

    <span class="clerk-product-info"
        {* Title *}
        {* Link URI *}
        data-url="{itemLink product=$product}"
        {* Product id *}
        {* Description *}
        data-description="Desc: {$productDescription|escape:"htmlall"|clearText}"
        {* Use SEO keywords for extra searchable keywords *}
        data-keywords="{$productController->getTranslation($product->Id, 'seo_keywords')|lower|escape:"htmlall"|clearText}"
        {* Image *}

        {* Thumbnail *}
        {* Item number *}

        {* Fetch the price line of the product *}
        {entity assign=priceLine controller=$priceController productId=$product->Id}
        {* Fetch the stock status text of the product *}
        {$stockStatusText = {stockStatusText product=$product inStockText='in stock' notInStockText='out of stock'}}
        {* Prices *}
        {assign price $priceLine->PriceMinWithVat}
        {if !$priceIncludingVat}
            {assign price $priceLine->PriceMinWithoutVat}
        {* Selling price *}
        {* Selling price - Formatted with language specific currency iso *}
        {$onSale = ($priceLine->PriceMinWithVat < $priceLine->FullPriceMinWithVat)}
        {* If the product is discounted we set the normal price as list price *}
        {if $onSale}
            {assign listPrice $priceLine->FullPriceMinWithVat}
            {if !$priceIncludingVat}
                {assign listPrice $priceLine->FullPriceMinWithoutVat}
            {* Normal price *}
            {* Normal price - Formatted with language specific currency iso *}
        data-on-sale="{if $onSale}true{else}false{/if}"
        data-in-stock="{if !$soldout}true{else}false{/if}"

        {* Product age *}

        {* If the product is newer than 30 days, we consider it as new *}
        {if $ageInDays lt 30}
        {* Brand *}
        {if !empty($brand->Title)}
            {$brandLink = "{$productPageLink}?brand={$brand->Id}-{$brand->Title|formatLink}"}

        {* If the product has variants *}
        {if $variants}
                {foreach $variants as $variant}
                    {if !empty($variant->ItemNumber)}
                        '{$variant->ItemNumber|escape:"htmlall"|clearText}'{if !$variant@last},{/if}

                {foreach $variants as $variant}
                    '{assign variantTitle {variantTitle productId=$product->Id variantId=$variant->Id}}{$variantTitle|escape:"htmlall"|clearText}'{if !$variant@last},{/if}
        {* Categories *}
                {if $product->SecondaryCategoryIds}
                    {foreach $product->SecondaryCategoryIds as $productCategory}
                        , {$productCategory}

Insert in Feed Slut Template

{*Add pagination*}
{if !isset($smarty.get.length)}
    {$length = 50}
    {$length = $smarty.get.length}

{if isset($smarty.get.start)}
    {$start = $smarty.get.start + $length}
    {$start = 0}

{* Check if out-of-stock products should be included*}
{if isset($smarty.get.include_out_of_stock)}
    {$stock = $smarty.get.include_out_of_stock}
    {$stock = "false"}

{*Get the name of the price-index*}
{$index = $smarty.get.index|replace:' ':"+"}

{* Create the next link for the crawler to follow *}
{if $product->Id}
     <a href="/framework/priceindex/?index={$index}&start={$start}&length={$length}&include_out_of_stock={$stock}"></a>

Save the Prisindex.

Afterwards you will have a link similar to this, available:

Go to -> Data.

Under Sync Method, choose HTML annotations, and insert your link.
Then set the Max Requests/Sec to 1 and choose the language.


Lastly, click Update Settings and then Start Sync.


Did this answer your question?