1 <?php
 2 /**
 3  * Export produktu z PrestaShopu
 4  *
 5  * @author Carlos, http://www.carlos-web.com
 6  * @version v1.0
 7  */
 8 
 9 /** URL adresa obchodu (bez posledniho lomitka) */
10 $shopUrl = 'http://www.VasShop.cz';  
11 
12 /** potlaceni chyb */
13 error_reporting(0);
14 
15 /** includes */
16 require_once(dirname(__FILE__) . "/config/config.inc.php");
17 require_once(dirname(__FILE__) . "/init.php");
18 
19 /** jazyk */
20 $lang = (isset($_GET["lang"])) ? intval($_GET["lang"]) : Configuration::get('PS_LANG_DEFAULT');
21 /** zobrazeni neaktivnich produktu */
22 $active = (!isset($_GET["noactive"]));
23 
24 /** hlavicky */
25 header("Content-type: text/xml"); //typ souboru
26 header("Pragma: no-cache");  //cache HTTP 1.0
27 header("Cache-Control: no-cache, must-revalidate");  //cahce HTTP 1.1
28 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
29 echo "<SHOP>\r\n"; //root
30 
31 /** produkty */
32 $products = Product::getProducts($lang, 0, 0, 'id_product', 'ASC', false, $active);
33 
34 /** vypis polozek */
35 foreach ($products as $p) {
36   echo "\t<SHOPITEM>\r\n";
37   echo "\t\t<PRODUCT>" . trim(htmlspecialchars($p["name"])) . "</PRODUCT>\r\n";
38   echo "\t\t<DESCRIPTION>" . trim(htmlspecialchars(strip_tags($p["description"]))) ."</DESCRIPTION>\r\n";
39   echo "\t\t<URL>" . $shopUrl ."/" . $p["id_product"] . "-" . trim($p["link_rewrite"]) . ".html</URL>\r\n";
40   $imgInfo = Product::getCover(intval($p["id_product"]));
41   if ($imgInfo != null)  {
42       $imgName = $p["id_product"] . "-" . $imgInfo["id_image"] . ".jpg"; //soubor s obrazkem
43       if (file_exists(_PS_PROD_IMG_DIR_ . $imgName)) {
44         echo "\t\t<IMGURL>" . $shopUrl . "/img/p/" . $imgName . "</IMGURL>\r\n";
45       }
46   }
47   echo "\t\t<PRICE>" . number_format ($p["price"], 2,".","") . "</PRICE>\r\n";
48   echo "\t\t<VAT>" . number_format ($p["tax_rate"], 0,".","") . "</VAT>\r\n";
49   echo "\t\t<PRICE_VAT>" . number_format ($p["price"] * (1 + ($p["tax_rate"] / 100)), 2,".","") . "</PRICE_VAT>\r\n";
50   echo "\t\t<DELIVERY_DATE>0</DELIVERY_DATE>\r\n";
51   if (mb_strlen($p["manufacturer_name"]) > 0) {
52     echo "\t\t<MANUFACTURER>" . trim(htmlspecialchars($p["manufacturer_name"])) . "</MANUFACTURER>\r\n";  
53   }
54   $category = new Category(intval($p["id_category_default"]), $lang);
55   echo "\t\t<CATEGORYTEXT>" . trim(htmlspecialchars($category->name)) . "</CATEGORYTEXT>\r\n";
56   unset($category);
57   echo "\t</SHOPITEM>\r\n";
58 }
59 
60 //konec feedu
61 echo "</SHOP>";
62 ?>