Item exports

With the item exports not only existing exports can be used to price portals, also complete new connections to new marketplaces can be created. By using an export template, which works with Smarty variables, adaptations / extensions new exports can be created quickly.

So you can create either text-, XML- or CSV files, depending on the requirements of each portal.

In most portals, a link to the export file can be stored. Depending on the caching method of your export the portal always gets the newest feed, but the shop has to generate it each time - on the other hand the file is created periodically and the portal gets the file much quicker, but it may not be the newest (depending on the renewal interval).

The basics

The interface

Opening the module shows you an overview of previously created export feeds. The interface offers the following basic functionalities:

  • Add: Add a new feed from the scratch.
  • Duplicate feed: This opens a new window with the exact same data from the duplicated export feed. Saving this feed creates a new export feed.
  • Edit feed: Click the pen icon to edit the feed.
  • Delete feed: Deletes the marked export feed.

Getting the Feed URL

There are 2 ways to get the export feed URL:

  • Via Shopware: Rightclick on the file name of the feed and choose copy link address.
  • 'Via file system (needs caching!): Open your export feed and keep the hash and the file name in mind. Then open the file system and navigate to /var/cache/production_REVISION/productexport/. The file is stored there as HASH_FILENAM, for example 4ebfa063359a73c356913df45b3fbe7f_export.txt.

Export Feeds

Now we go over to the exports itself and show you, how easy you can create and edit export feeds.

Depending on your needs you need programming knowledge to individualize your export feeds, when you don't have these knowledge, you shouldn't edit your feeds, otherwise your export feeds can break.

Basic settings for all feeds

  • Title: Name of the feed (relevant for the description in the product export overview)
  • File name: Name of the created file, which is also a part of the filename on the server.
  • Partner ID: The Partner ID will be attached to all article links, so your partners of the Affiliate program can assign the orders to you. This will also be considered in the statistics and make your orders more transparent.
  • Hash The hash will be generated automatically for each feed, it's another part of the filename on your server and will also be implemented in the URL to the XML / CSV. If you change this key, the price search engine looses access to the feed.
  • Active: Activates or deactivates the feed.
  • Caching interval: Here you can set the interval for caching the feed. You can choose Only Cron (The feed will only be created via cronjob - recommended for feeds with much items), Live (The feed will be generated every time live - slow in case of much items) or your favourite caching interval (will be cached the setted interval, but then it will be regenerated at calling the URL - generating may be slow with many items), which will generate the feed only in the given interval. Between this interval, the feed is cached. Noticethat saving a feed in the backend will automatically clear the cache for that feed and the file needs to be regenerated! Not until then the cachings will work as configured!
    • If you want to export the feed only via cron, activate the cronjob 'Cron Product Export' plugin, which includes the feed cache cron task. This cron task generates files inside the '/var/cache/production_REVISION/productexport' folder of your Shopware installation. If you use the cron task, please keep in mind that the files in this folder need to be accessible (read and write) by both your cron execution user and your web server user.
  • Last export: Shows the timestamp of the last export.
  • Shop: When you're using language- or subshops with different URLs / domains, this setting chooses the right (virtual-)URL and image for the export items.
  • Customer group: Sets the customer group, from which the prices were taken. (default: Shopkunden)
  • Currency: Choose the currency for the item prices. Notice, that the currency also will convert the prices.
  • Category: Hereby you can export items only from the chosen category. For subshops it's recommended to choose the main category of the subshop.
  • Export variants:' Here you can set, whether you want to export all variants with their data or just the basic items. If you choose No, only the preselected variant of an item with it's data will be exported.
  • Last cache refresh: Shows the timestamp of the last cache refresh.

Extended settings

Format

  • Encoding: by default ISO-8859-1 for CSV/TXT and UTF-8 for XML feeds
  • File format: Setting the file format (CSV/XML/TXT)

Header

Here you define the column names of the csv file, e.g. id, supplier, model, name, category etc. In a XML file the header must be placed here too, e.g. Start tag, title, description etc.

Body

Here you can define the template of the export items. The body will loop over every item. In CSV / TXT exports you get one row per item. In XML exports, e.g. Google, every item must be marked by a start tag and a end tag. In this way it's possible to arrange a individual settings.

List of available variables

VariableDescription
{$sConfig.sBASEPATH}URL to shop
{$sConfig.sSHOPNAME}name of shop
VariableDescription
{$sSettings.feedID}ID of export
{$sSettings.name}name of item export
{$sSettings.last_export}date last run
{$sSettings.hash}access hash
{$sSettings.count_articles}products in last run
{$sSettings.formatID}file format ID
{$sSettings.filename}filename
{$sSettings.encodingID}Coding ID
{$sSettings.categoryID}main category
{$sSettings.currencyID}currency ID
{$sSettings.customergroupID}customergroup ID
{$sSettings.partnerID}partner ID
{$sSettings.languageID}language ID
{$sSettings.multishopID}shop ID
{$sSettings.variant_export}export variants?
{$sSettings.encoding}coding
filter definitionsdescription
{$sSettings.active_filter}only active items
{$sSettings.image_filter}only items with pictures
{$sSettings.stockmin_filter}instock lower stockmin
{$sSettings.instock_filter}instock lower
{$sSettings.price_filter}price less ...
{$sSettings.own_filter}own filters
{$sSettings.count_filter}max. items in export
{$sSettings.header}header own filter
{$sSettings.footer}footer
{#F#}field separation
{#EF#}Escaped-field separation
{#S#}delimiter
{#ES#}Escaped-delimiter
{#L#}row delimiter
{#EL#}Escaped-row delimiter

The following variables can only be used in body:

item variables:

VariableDescription
{$sArticle.articleID}item ID
{$sArticle.name}item name
link:$sArticle.name|escape}article URL
{$sArticle.description}short description
{$sArticle.description_long}description
{$sArticle.shippingtime}shipping/delivery time (in days)
{$sArticle.added}item added
{$sArticle.shippingfree}shipping free
{$sArticle.releasedate}release date
{$sArticle.topseller}highlited item
{$sArticle.keywords}keywords
{$sArticle.minpurchase}min purchase
{$sArticle.purchasesteps}purchase steps
{$sArticle.maxpurchase}max purchase
{$sArticle.purchaseunit}price related to (unit)
{$sArticle.referenceunit}reference unit
{$sArticle.taxID}tax ID
{$sArticle.supplierID}supplier ID
{$sArticle.unitID}unit ID
{$sArticle.unit_description}unit
{$sArticle.changed}date last changes
{$sArticle.active}item active
{$sArticle.variantActive}active state of the variant
{$sArticle.articledetailsID}item detail ID
{$sArticle.ordernumber}ordernumber
{$sArticle.suppliernumber}suppliernumber
{$sArticle.standard}default variant
{$sArticle.additionaltext}variant descriprion
{$sArticle.impressions}impressions
{$sArticle.sales}sales
{$sArticle.instock}instock
{$sArticle.stockmin}min instock
{$sArticle.laststock}clearance sale
{$sArticle.esd}download item (esd)
{$sArticle.weight}weight
{$sArticle.ean}EAN
{$sArticle.position}position
{$sArticle.attr1} bis {$sArticle.attr20}item attributes
{$sArticle.supplier}supplier
{$sArticle.unit}unit
{$sArticle.tax}tax
{$sArticle.image}item picture
{$sArticle.netprice}net price
{$sArticle.price}gros price
{$sArticle.netprice_numeric}net price rounded like in the frontend
{$sArticle.price_numeric}gross price rounded like in the frontend
{$sArticle.purchaseprice}purchase price
{$sArticle.netpseudoprice}net pseudo price
{$sArticle.pseudoprice}gross pseudo price
{$sArticle.baseprice}base price
{$sArticle.discount}price group discount
{$sArticle.sVoteCount}count ratings
{$sArticle.sVoteAverage}average ratings
{$sArticle.metaTitle}Meta Title
{$sArticle.pseudosales}pseudo sales
{$sArticle.notification}email notification active?
{$sArticle.available_from}price group active?
{$sArticle.available_to}ID of the selected price group
{$sArticle.pricegroupActive}available from
{$sArticle.pricegroupID}available until

{$sArticle.articleID|category:" > "|escape}
display categories / breadcrumb

* with {$sArticle.image|image:1} or {$sArticle.image|image:2} etc. you can use different thumbnail sizes.

Additional variables:

commandDescription
strip_tagsfilter html source code
stripdelete duplicate spaces and replaced line breaks by spaces
trimdeletes unnecessary spaces
truncate:500truncate description to 500 chars
html_entity_decodeconvert umlauts
escapeconvert special character in html, z.B. & = &
escape:xmlEncoding only for xml
@shippingcostcalculate shipping costs for item
format:"number"formats numbers for each localization

Footer

The footer is used exclusively for the XML exports. The start tags, which you configured in the header, must be closed here. Example Google:


</channel>
</rss>

Blocked categories

Here the complete category tree is rendered. If you check some categories, they are generally excluded from the export.

Even if items are associated with multiple categories: When an item is associated with a category which is blocked, the item won't be exported.

Supplier filter

On the left panel there is a list of all suppliers of your shop, here you can search by manufacturers or choose them directly from the list. To exclude items from a specific manufacturer on exports, just add the supplier by double-clicking to the list of blocking manufacturer (right list). Alternatively you can mark the entry and click the arrow in the specific direction.

Item filter

The item filter works the same ways as the supplier filter, on the left you get the list of all items in your shop, to exclude an item just add it by double-clicking to the list of blocked items. Alternatively you can also here mark the items and click the arrow in the specific direction.

Additional filters

  • Price higher than: E.g. 1000 - Export of items with price >= 1000
  • Stock larger than: E.g. 10 - Export of item with Stock >= 10
  • Max. number of items: Limits the output of items in the feed to the entered value
  • Stock below minimum inventory: Items with actual Stock < minimum Stock will be excluded from the feed.
  • Activated items only: If active, only the active items will be exported.
  • Filters: This field requires MySQL Knowledge. Here you can use e.g. the following filters:
    • at.attr6=""true" - Attribute 6 is true
    • a.topseller="true" - Exports only highlighted items
    • d.releasedate>=CURDATE() OR d.releasedate= 0000-00-00 - Article is still released
    • SELECT 1 FROM s_articles_categories WHERE articleID=a.id AND categoryID=42 - All items from category-ID 42
    • d.ean!="" - Exports articles containing an EAN
    • a.id in (select articleid FROM s_articles_details group by articleid having count(id)>=50000 and count(id)<=100000) - offset all products bewteen 50.000 and 100.000
      DAYOFWEEK(NOW()) not in (2, 5) - all weekdays but tuesday and thursday
      (time(now()) > '10:00:00' and time(now()) < '12:00:00' ) or (time(now()) > '17:00:00' and time(now()) < '22:00:00' ) - time between 10:00 and 12:00 or 17:00 and 22:00 oclock
  • Items with images only: If active, only items with images will be exported.

Free text fields

Here you can define free text fields for your export feed. To use this, please take a look in the documentation of Free text field management

Tips & Tricks

Base price export

By adding the following example you can export the base price and the content of your items:

Header


Base price{#S#}
Content{#S#}

Template


{if $sArticle.referenceunit && $sArticle.purchaseunit}
{assign var="sArticleReferenceprice" value=$sArticle.price/$sArticle.purchaseunit*$sArticle.referenceunit}
{$sArticle.referenceunit} {$sArticle.unit} = {$sArticleReferenceprice|escape:"number"}{#S#}
{$sArticle.purchaseunit} {$sArticle.unit}{#S#}
{else}
{#S#}{#S#}
{/if}

Additionaltext export

At first, this can only work, if Export variants is active. To export your configurator items, use it how we do it in our example:

Configurator variablesoutcome
{$sArticle.additionaltext}blue / XL

If you export configurator items and them variants, it makes sense to extend the header. To avoid duplicate item names we recommend that you add the additional text to the body with {$sArticle.additionaltext}

So you can use this body:


{$sArticle.name|strip_tags|strip|truncate:80:"...":true|escape|htmlentities} {$sArticle.additionaltext|escape}{#S#}

for getting this feed content:

Nova Jacket blue / XL

Article properties

If you want to, you can export item properties with the following syntax in your body:


{assign var="properties" value=$sArticle.articleID|property:$sArticle.filtergroupID}
{foreach from=$properties item=property}
    {if $property}
        {$property.groupName|escape}: {$property.name|escape}: {$property.value|escape}
    {/if}
{/foreach}

This will give you all properties of your item.

Article (variant) images

The following syntax exports the image which is attached to a specific variant of the item and all unassigned images: {$sArticle.articleID|articleImages:$sArticle.ordernumber:2:">"|escape}

The 'articleImages' call accepts a second argument ('>' above) which is used as the separator in case multiple images exist.

If you want to export just the first variant image, you can use the following method: The template must be prepended (before the strip tag) by the following code:


{assign var="string" value=$sArticle.articleID|articleImages:$sArticle.ordernumber:2:"##"|escape}
{assign var="productVariantImage" value="##"|explode:$string}

This code is getting the images and put these in a string, which you can edit later.

In the image section of your template you can use the following code:


{$productVariantImage[0]}

0 hereby is the image number whereby 0 is always the first image.

The variant can also be called directly. To use this function you have to append the article url with the parameter ?number="ordernumber from the variant".

  • Example for the product export without a partner ID:

 {$sArticle.articleID|link:$sArticle.name}{if $sArticle.additionaltext}?number={$sArticle.ordernumber}{/if}
  • Example for the product export with a partner ID:

 {$sArticle.articleID|link:$sArticle.name}{if $sArticle.additionaltext}?number={$sArticle.ordernumber}&PARTNER-TAG{/if}?PARTNER-TAG

Surcharge in item feeds

Because the template is based on smarty, you also can calculate here.

Some price search engines will compare your feed price with the detail page price and will give you an error, if the prices don't match.

Percental surcharge

The following example will surcharge the item by 5%:


// Before:
{$sArticle.price|escape:"number"}{#S#}

// After:
{$sArticle.price*1.05|escape:"number"}{#S#}

General surcharge

In this example, a general surcharge of 0.50 of the desired currency will be added:


// Before:
{$sArticle.price|escape:"number"}{#S#}

// After:
{$sArticle.price+0.50|escape:"number"}{#S#}

Why are not all products exported?

When items won't be exported, this can have multiple reasons, you should check the following settings:

  • Check, if you use a limit for items to export
  • Check the filter settings
  • Check if the server can handle the export. In case of many items to export, the server may run into the "memory_limit", which cancels the generation process. If this happens, please contact your hoster because this is a server setting which has nothing to deal with Shopware.

If you exclude categories from export, you also exclude all items in this category. 
Example: When your item is assigned to category A and B and you exclude B, the item is nevertheless excluded from the export, even if it's assigned to A.

Configurator options in own columns

With Shopware 5.2.9 you can output configurator options in own columns instead of output the additionaltext only, so that the item is more clear for the price search engine.

XML dynamic

Dynamic works only, if you have configurator groups & options, which are NOT written with whitespaces!

The following code must be pasted in the template:


{foreach $sArticle.configurator_options as $option}
  <{$option@key}>{$option}</{$option@key}>
{/foreach}

XML static

The following code must be pasted in the template:


<color>{$sArticle.configurator_options['Color']}</color>
<size>{$sArticle.configurator_options['Size']}</size>

"Color" and "Size" are examples and must be changed to your own configurator group name.

CSV static

First, paste the name of your desired configurator group in the header at the desired position:


color{#S#}
size{#S#}

The following code must be pasted in the template at the respective position:


{$sArticle.configurator_options['Color']}
{$sArticle.configurator_options['Size']}

"Color" and "Size" are examples and must be changed to your own configurator group name.

Active and inactive variants

You can export the active state of each variant, if your desired price search engine supports that feature. To use it, you have to export variants, add a new column in the header and in the template. The header is done by using active{#S#}.

In the template, just add the variable at the same column: {$sArticles.variantActive}{#S#}

The feed will then export each variants active state.

Was this article helpful?