From the marketing point of view, it is almost necessary to register e-shops in product search engines / comparators today. At the present time, a great number of such servers is available and here we will show you how to prepare an XML feed for such servers.
Implementing a Code for XML File Generation
All of such product search engines download periodically an XML file from your server. Fortunately, the format of this XML file is almost the same for all of these search engines (some search engines use all items, some only some of them). The format of this file can be found, for example, at this URL address:
http://help.seznam.cz/cz/specifikace-xml.html.
To have the resulting XML file updated all the time, it is necessary to generate this XML file each time when any change of a record in the
m_shop_catalogue table occurs. That is why it is necessary to insert a code into the
onChange event of the
m_shop_catalogue table. Therefore, go to the
Presentation -> Tables menu, open the
m_shop_catalogue table for editing and insert the following code into the
onChange event:
// An empty file with write access 777 will be created _file_put_contents(MAINPATH."zbozi-seznam.xml", "");
$file = fopen(MAINPATH."zbozi-seznam.xml", "w");
fwrite($file, '<?xml version="1.0" encoding="utf-8"?>');
fwrite($file, '<SHOP>');
// the getContentRecords function loads records in a similar way as getRecords() does, with the difference that it applies initial filters (records that are in the archive are not loaded)
$records = getTable("m_shop_catalogue")->getContentRecords();
foreach($records as $record)
{
fwrite($file, '<SHOPITEM>');
fwrite($file, '<PRODUCT>'.htmlspecialchars($record["name"]).'</PRODUCT>');
fwrite($file, '<DESCRIPTION>'.htmlspecialchars(_substr(strip_tags($record["description"]),0,500)).'...</DESCRIPTION>');
fwrite($file, '<URL>'.htmlspecialchars(toSEOUrl('m_shop_catalogue.php?id='.$record["id"])).'</URL>');
fwrite($file, '<IMGURL>'.htmlspecialchars(getTable("m_shop_catalogue")->getComponent("image")->getUrl($record)).'</IMGURL>');
fwrite($file, '<VAT>'.$record["tax"].'</VAT>');
fwrite($file, '<PRICE_VAT>'.$record["taxPrice"].'</PRICE_VAT>');
fwrite($file, '<AVAILABILITY>0</AVAILABILITY>');
fwrite($file, '</SHOPITEM>');
}
fwrite($file, '</SHOP>');
fclose($file);
If an administrator enters a new record, edits any existing one or deletes any record (in all cases the
onChange event is called), the aforementioned code will be run that will generate an XML file again. The resulting XML file can be found at this URL address: http://www.domena.cz/zbozi-seznam.xml.
Registering Your E-shop in Product Search Engines
Some servers check themselves the content of this file just on registration; therefore, we have to create this XML file. As the
onChange event calls only when the
m_shop_catalogue table content changes, it is necessary to open and save at least 1 record in this table in administration to run this code in order to generate this XML file for the first time (this file will not be created by mere entering the code into the event of this table; it is necessary to run this code just by editing any record).
Some product search engines are free of charge, some require placing a backlink or banner on the pages, and others are to be paid fully. At the present time, there are the following product search engines (sorted by importance):
If you decide to register in all of the aforementioned product search engines, please plan work for roughly 2 hours.