Shopmania Xml Data Feed

Network Destek

Network Destek

Yönetici
Opencart Uzmanı
Katılım
15 Ocak 2012
Mesajlar
46
Tepkime puanı
3
Puanları
10,001
Web sitesi
opencartfrm.com
Bu data feed sayaesinde sitenizde olan ürünlerinizi shopmania'da ücretsiz yayınlayabilirsiniz.
PHP:
<?php
 
##########################################################################################
# In order to be able to use this script you need to join the merchant program depending on the country where your store is selling the products
#
# AUSTRALIA - http://shopmania.com.au/ (only supporting AUD, NZD datafeeds)
# ARGENTINA - http://www.shopmania.com.ar/ (only supporting ARS, EUR, USD)      *NEW
# BRASIL - http://www.shopmania.com.br/ (only supporting BRL, USD)
# BULGARY - http://www.shopmania.bg/ (only supporting BGN, EUR, USD)
# CZECH REPUBLIC - http://www.shop-mania.cz/ (only supporting CZK, EUR, USD)        *NEW
# CHILE - http://www.shopmania.cl/ (only supporting CLP, USD, EUR)      *NEW
# CHINA - http://www.shopmania.cn/ (only supporting CNY, USD)     
# DEUTSCHLAND - http://www.shopmania.de/ (only supporting EUR, USD)
# FRANCE - http://www.shopmania.fr/ (only supporting EUR, USD datafeeds)
# HUNGARY - http://www.shopmania.hu/ (only supporting HUF, EUR, USD datafeeds)
# INDIA - http://www.shopmania.in/ (only supporting INR, USD datafeeds)
# IRELAND - http://www.shopmania.ie/ (only supporting EUR, GBP datafeeds)
# ITALY - http://www.shopmania.it/ (only supporting EUR, USD datafeeds)
# JAPAN - http://www.shopmania.jp/  (only supporting JPY, USD datafeeds)     
# MEXICO - http://www.shopmania.com.mx/ (only supporting MXN (Mexican peso), USD, EUR datafeeds)
# NETHERLANDS - http://www.shopmania.nl/ (only supporting EUR datafeeds)        *NEW
# POLSKA - http://www.shopmania.pl/ (only supporting PLN, EUR, USD)
# PORTUGAL - http://www.shopmania.pt/ (only supporting EUR, USD)
# ROMANIA - http://www.shopmania.ro/ (only supporting RON, EUR, USD datafeeds)
# RUSSIA - http://www.shopmania.ru/ (only supporting RUB, EUR, USD)     
# SERBIA - http://www.shopmania.rs/ (only supporting RSD, EUR)        *NEW   
# SLOVAKIA - http://www.shop-mania.sk/ (only supporting EUR, USD)
# SOUTH AFRICA - http://www.shopmania.co.za/ (only supporting ZAR, USD, EUR)      *NEW
# SPAIN - http://www.shopmania.es/ (only supporting EUR datafeeds)
# SWEDEN - http://www.shopmania.se/ (only supporting SEK, EUR, USD datafeeds)        *NEW
# TURKEY - http://www.shopmania.com.tr/ (only supporting TRY, EUR, USD)
# US - http://www.shopmania.com/ (only supporting USD, CAD datafeeds)
# UK - http://www.shopmania.co.uk/ (only supporting GBP, EUR, USD datafeeds)
#
# Once you join the program and your application is approved you need to place the file on your server and set up the path to the file on the Merchant Interface
# Files will be  retrieved daily from your server having the products listed automatically on ShopMania
#
#
# Options
# @url_param taxes=on (on,off)
# @url_param storetaxes=on (on,off)
# @url_param discount=on (on,off)
# @url_param add_vat=off (on,off)
# @url_param vat_value=24 (VAT_VALUE)
# @url_param shipping=off (on,off)
# @url_param add_tagging=on (on,off)
# @url_param tagging_params=&utm_source=shopmania&utm_medium=cpc&utm_campaign=direct_link (TAGGING_PARAMS)
# @url_param description=on (on,off)
# @url_param image=on (on,off)
# @url_param specialprice=on (on,off)
# @url_param sef=off (on,off)
# @url_param on_stock=off (on,off)
# @url_param forcepath=off (on,off)
# @url_param forcefolder= (FORCEFOLDER)
# @url_param language= (LANGUAGE_CODE)
# @url_param language_id= (LANGUAGE_ID)
# @url_param currency= (CURRENCY_CODE)
#
#
#########################################################################
 
// Current datafeed script version
$script_version = "1.14";
 
// Print current Script version
if (@$_GET['get'] == "version") {
    echo "<b>Datafeed OpenCart</b><br />";
    echo "script version <b>" . $script_version . "</b><br />";
    exit;
}
 
// Print URL options
if (@$_GET['get'] == "options") {
    $script_basepath = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
   
    echo "<b>Datafeed OpenCart</b><br />";
    echo "script version <b>" . $script_version . "</b><br /><br /><br />";
       
    echo "<b>Opencart 1.4 compatibility mode</b> Use this when this error appears(Error: Unknown column 'store_id' in 'where clause')<br />";
    echo "version=1.4  <a href=\"" . $script_basepath . "?version=1.4" . "\" >" . $script_basepath . "?version=1.4" . "</a><br /><br />";
}
 
// Set no time limit only if php is not running in Safe Mode
if (!ini_get("safe_mode")) {
    @set_time_limit(0);
    if (((int)substr(ini_get("memory_limit"), 0, -1)) < 256) {
        ini_set("memory_limit", "256M");
    }
}
 
ignore_user_abort();
error_reporting(E_ALL^E_NOTICE);
$_SVR = array();
 
##### Include configuration files ################################################
 
$site_base_path = "./";
 
if(!file_exists($site_base_path . "config.php")) {
    exit('<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>Please ensure that datafeed_shopmania_opencart.php is in the same folder with config.php file or define the path to config.php file in $site_base_path variable.</BODY></HTML>');
}
else {
    require($site_base_path . "config.php");
}
 
// Startup
require_once(DIR_SYSTEM . 'startup.php');
 
// Tax and customer
require_once(DIR_SYSTEM . 'library/customer.php');
require_once(DIR_SYSTEM . 'library/tax.php');
 
// Registry
$registry = new Registry();
 
// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);
 
// Config
$config = new Config();
$registry->set('config', $config);
 
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
 
// Check if store_id field exists (version > 1.5)
$settingtableFields = mysql_list_fields(DB_DATABASE, DB_PREFIX . "setting");
$columns_s = mysql_num_fields($settingtableFields);
     
for ($i = 0; $i < $columns_s; $i++) {
    $s_field_array[] = mysql_field_name($settingtableFields, $i);
}
 
// Determin opencart version
$oc_version = (@$_GET['version'] == "1.4") ? "1.4" : ((!in_array("store_id", $s_field_array)) ? "1.4" : "1.5");
 
if ($oc_version == "1.4") {
    // Settings
    $query = $db->query("SELECT * FROM " . DB_PREFIX . "setting");
}
else {
    // Settings
    $query = $db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '0' OR store_id = '" . (int)$config->get('config_store_id') . "' ORDER BY store_id ASC");
}
 
foreach ($query->rows as $setting) {
    if (!@$setting['serialized']) {
        $config->set($setting['key'], $setting['value']);
    } else {
        $config->set($setting['key'], unserialize($setting['value']));
    }
}
 
// Request
$request = new Request();
 
// Customer
$registry->set('customer', new Customer($registry));
 
// Tax
$tax = new Tax($registry);
$registry->set('tax', $tax);
 
####################################################################
 
// Datafeed specific settings
$datafeed_separator = "|"; // Possible options are \t or |
 
 
##### Extract params from url ################################################
 
$apply_taxes = (@$_GET['taxes'] == "off") ? "off" : "on";
$apply_storetaxes = (@$_GET['storetaxes'] == "off") ? "off" : "on";
$apply_discount = (@$_GET['discount'] == "off") ? "off" : "on";
$add_vat = (@$_GET['add_vat'] == "on") ? "on" : "off";
$vat_value = (@$_GET['vat_value'] > 0) ? ((100 + $_GET['vat_value']) / 100) : 1.24; // default value
$add_shipping = (@$_GET['shipping'] == "on") ? "on" : "off";
$add_availability = (@$_GET['availability'] == "off") ? "off" : "on";
$add_gtin = (@$_GET['gtin'] == "on") ? "on" : "off";
$add_tagging = (@$_GET['add_tagging'] == "off") ? "off" : "on";
$tagging_params = (@$_GET['tagging_params'] != "") ? urldecode($_GET['tagging_params']) : "utm_source=shopmania&utm_medium=cpc&utm_campaign=direct_link";
$show_description = (@$_GET['description'] == "off") ? "off" : ((@$_GET['description'] == "limited") ? "limited" : "on");
$show_image = (@$_GET['image'] == "off") ? "off" : "on";
$show_specialprice = (@$_GET['specialprice'] == "off") ? "off" : "on";
$sef = (@$_GET['sef'] == "on") ? "on" : "off";
$on_stock_only = (@$_GET['on_stock'] == "on") ? "on" : "off";
$currency = (@$_GET['currency'] != "") ? $_GET['currency'] : "";
$display_currency = (@$_GET['display_currency'] != "") ? $_GET['display_currency'] : "";
$language_code = (@$_GET['language'] != "") ? $_GET['language'] : "";
$language_id = (@$_GET['language_id'] != "") ? $_GET['language_id'] : "";
$force_path = (@$_GET['forcepath'] == "on") ? "on" : "off";
$force_folder = (@$_GET['forcefolder'] != "") ? $_GET['forcefolder'] : "";
$limit = (@$_GET['limit'] > 0) ? $_GET['limit'] : "";
 
####################################################################
 
// Get currency
if($currency != "") {
    $add_currency = 1;
    $currency_code = $_GET['currency'];
}
else {
    $add_currency = 0;
}
 
if (!defined('HTTP_SERVER')) {
    define('HTTP_SERVER', 'http://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/') . '/');
}
if (!defined('HTTP_IMAGE')) {
    define('HTTP_IMAGE', HTTP_SERVER . 'image/');
}
 
// Print URL options
if (@$_GET['get'] == "options") {
    $script_basepath = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
       
    //echo "<b>Store taxes options</b> - possible values on, off default value on<br />";
    //echo "storetaxes = on (on,off) <a href=\"" . $script_basepath . "?storetaxes=off" . "\" >" . $script_basepath . "?storetaxes=off" . "</a><br /><br />";
   
    //echo "<b>Discount options</b> - possible values on, off default value on<br />";
    //echo "discount=on (on,off) <a href=\"" . $script_basepath . "?discount=off" . "\" >" . $script_basepath . "?discount=off" . "</a><br /><br />";
   
    echo "<b>Add VAT to prices</b> - possible values on, off default value off<br />";
    echo "add_vat=off (on,off) <a href=\"" . $script_basepath . "?add_vat=on" . "\" >" . $script_basepath . "?add_vat=on" . "</a><br /><br />";
   
    echo "<b>VAT value</b> - possible values percent value default value 24  - interger or float number ex 19 or 19.5<br />";
    echo "vat_value=24 (VAT_VALUE) <a href=\"" . $script_basepath . "?add_vat=on&vat_value=19" . "\" >" . $script_basepath . "?add_vat=on&vat_value=19" . "</a><br /><br />";
   
    //echo "<b>Add shipping to datafeed</b> - possible values on, off default value off <br />";
    //echo "shipping=off (on,off) <a href=\"" . $script_basepath . "?shipping=on" . "\" >" . $script_basepath . "?shipping=on" . "</a><br /><br />";
   
    echo "<b>Add availability to datafeed</b> - possible values on, off default value on<br />";
    echo "availability=on (on,off) <a href=\"" . $script_basepath . "?availability=off" . "\" >" . $script_basepath . "?availability=off" . "</a><br /><br />";
   
    echo "<b>Add GTIN to datafeed</b> - possible values on, off default value on (versions 1.5 or higher)<br />";
    echo "gtin=off (on,off) <a href=\"" . $script_basepath . "?gtin=on" . "\" >" . $script_basepath . "?gtin=on" . "</a><br /><br />";
   
    echo "<b>Add GA Tagging to product URL</b> - possible values on, off default value on<br />";
    echo "add_tagging=on (on,off) <a href=\"" . $script_basepath . "?add_tagging=off" . "\" >" . $script_basepath . "?add_tagging=off" . "</a><br /><br />";
   
    echo "<b>Add custom Tagging to product URL</b> - possible values url_encode(TAGGING_PARAMS) default value tagging_params=utm_source=shopmania&utm_medium=cpc&utm_campaign=direct_link<br />";
    echo "tagging_params=utm_source=shopmania&utm_medium=cpc&utm_campaign=direct_link (TAGGING_PARAMS) <a href=\"" . $script_basepath . "?tagging_params=from%3Dshopmania" . "\" >" . $script_basepath . "?tagging_params=from%3Dshopmania" . "</a><br /><br />";
   
    echo "<b>Display Description options</b> - possible values on, off, limited default value on<br />";
    echo "description=on (on,off) <ul><li><a href=\"" . $script_basepath . "?description=off" . "\" >" . $script_basepath . "?description=off" . "</a></li>";
    echo "<li><a href=\"" . $script_basepath . "?description=limited" . "\" >" . $script_basepath . "?description=limited" . "</a></li></ul>";
 
    echo "<b>Display image options</b> - possible values on, off default value on<br />";
    echo "image=on (on,off) <a href=\"" . $script_basepath . "?image=off" . "\" >" . $script_basepath . "?image=off" . "</a><br /><br />";
   
    //echo "Special price options - possible values on, off default value on<br />";
    //echo "specialprice=on (on,off) <a href=\"" . $script_basepath . "?specialprice=off" . "\" >" . $script_basepath . "?specialprice=off" . "</a><br /><br />";
   
    echo "<b>Show only on stock products</b> - possible values on, off default value off<br />";
    echo "on_stock=off (on,off) <a href=\"" . $script_basepath . "?on_stock=on" . "\" >" . $script_basepath . "?on_stock=on" . "</a><br /><br />";
   
    echo "<b>Show SEO friendly url</b> - possible values on, off default value off<br />";
    echo "sef=off (on,off) <a href=\"" . $script_basepath . "?sef=on" . "\" >" . $script_basepath . "?sef=on" . "</a><br /><br />";
   
    echo "<b>Get prices in specified currency</b> - possible values USD,EUR etc. <br />";
    echo "currency=DEFAULT_CURRENCY <a href=\"" . $script_basepath . "?currency=EUR" . "\" >" . $script_basepath . "?currency=EUR" . "</a><br /><br />";
   
    echo "<b>Force displayed currency</b> - possible values USD,EUR etc. <br />";
    echo "display_currency= <a href=\"" . $script_basepath . "?display_currency=EUR" . "\" >" . $script_basepath . "?display_currency=EUR" . "</a><br /><br />";
       
    echo "<b>Get texts in specified language code</b> - possible values en,ro etc. <br />";
    echo "language=DEFAULT_LANGUAGE_CODE <a href=\"" . $script_basepath . "?language=en" . "\" >" . $script_basepath . "?language=en" . "</a><br /><br />";
   
    echo "<b>Get texts in specified language id</b> - possible values 1,2 etc. <br />";
    echo "language_id=DEFAULT_LANGUAGE_ID <a href=\"" . $script_basepath . "?language_id=1" . "\" >" . $script_basepath . "?language_id=1" . "</a><br /><br />";
   
    echo "<b>Limit displayed products</b> - limit the number of displayed products - possible values (integer) <br />";
    echo "limit=no_limit <a href=\"" . $script_basepath . "?limit=10" . "\" >" . $script_basepath . "?limit=10" . "</a><br /><br />";
 
    echo "<br />";
   
    exit;
   
}
 
 
##### Extract options from database ################################################
 
// Get Settings
$res_setting = mysql_query("SELECT * FROM " . DB_PREFIX . "setting WHERE " . DB_PREFIX . "setting.group='config' ") or die(mysql_error());
 
$SETTING = array();
 
if ($res_setting) {
    while ($field = mysql_fetch_assoc($res_setting)) {
        $SETTING[$field['key']] = $field['value'];
    }
}
 
if ($language_id > 0) {
    // Set the main language
    $main_language = $language_id;
}
elseif ($language_code != "") {
    // Detect default language ID
    $query_language_id = mysql_query("SELECT language_id FROM " . DB_PREFIX . "language WHERE code='" . $language_code . "' LIMIT 1") or die("Language id: " . mysql_error());
    $row_language_id = mysql_fetch_array($query_language_id);
 
    // Set the main language
    $main_language = $row_language_id['language_id'];
}
else {
    // Detect default language code
    $query_language_code = mysql_query("SELECT value FROM " . DB_PREFIX . "setting WHERE " . DB_PREFIX . "setting.key='config_language'") or die("Language code: " . mysql_error());
    $row_language_code = mysql_fetch_array($query_language_code);
 
    $language_code = $row_language_code['value'];
   
    // Detect default language ID
    $query_language_id = mysql_query("SELECT language_id FROM " . DB_PREFIX . "language WHERE code='" . $language_code . "' LIMIT 1") or die("Language id: " . mysql_error());
    $row_language_id = mysql_fetch_array($query_language_id);
 
    // Set the main language
    $main_language = $row_language_id['language_id'];
}
 
// Get default currency
$res_currency = mysql_query("SELECT value FROM " . DB_PREFIX . "setting WHERE " . DB_PREFIX . "setting.key='config_currency'") or die("Currency code: " . mysql_error());
if ($res_currency) {
    while ($field = mysql_fetch_assoc($res_currency)) {
        $datafeed_currency = $field['value'];
    }
}
 
if ($add_currency == 1) {
    $res_currency_2 = mysql_query("SELECT value FROM " . DB_PREFIX . "currency WHERE code LIKE '" . $_GET['currency'] . "'");
    if ($res_currency_2) {
        $field = mysql_fetch_assoc($res_currency_2);
        $currency_value = $field['value'];
        $datafeed_currency = strtoupper($_GET['currency']);
    }
}
 
// Overite currency with forced value
$datafeed_currency = ($display_currency != "") ? $display_currency : $datafeed_currency;
 
// Overite Sef options with config values
$sef = ($SETTING['config_seo_url'] == 1 && @$_GET['sef'] != "off") ? "on" : $sef;
 
// Get categories
$cat_res = mysql_query("SELECT * FROM " . DB_PREFIX . "category
    LEFT JOIN " . DB_PREFIX . "category_description ON (" . DB_PREFIX . "category.category_id = " . DB_PREFIX . "category_description.category_id)
    WHERE language_id = '" . $main_language . "'") or die("Category: " . mysql_error());
if ($cat_res) {
    while($field = mysql_fetch_assoc($cat_res)) {
        $CAT_ARR[$field['category_id']] = $field;
    }
}
 
$SEO_ARR = array();
if ($sef == "on") {
    // Get SEO links
    $seo_res = mysql_query("SELECT SUBSTRING(" . DB_PREFIX . "url_alias.`query`, 12) prod_id, " . DB_PREFIX . "url_alias.* FROM " . DB_PREFIX . "url_alias
    WHERE SUBSTRING(" . DB_PREFIX . "url_alias.`query`, 1,10) = 'product_id'") or die("SEO keywords: " . mysql_error());
    if ($seo_res) {
        while($field = mysql_fetch_assoc($seo_res)) {
            $SEO_ARR[$field['prod_id']] = $field['keyword'];
        }
    }
}
 
// Get special prices for product
$res_special_price = mysql_query("SELECT product_id, price
    FROM " . DB_PREFIX . "product_special
    WHERE (date_start <= DATE_FORMAT(NOW(), '%Y-%m-%d') OR date_start = '0000-00-00') AND (date_end >= DATE_FORMAT(NOW(), '%Y-%m-%d') OR date_end = '0000-00-00')
    ORDER BY customer_group_id DESC") or die(mysql_error());
 
if ($res_special_price) {
    while ($field = mysql_fetch_assoc($res_special_price)) {
        $SPECIAL_PRICE[$field['product_id']] = $field['price'];
    }
}
 
// Get stock statuses
$stock_res = mysql_query("SELECT * FROM " . DB_PREFIX . "stock_status
    WHERE language_id = '" . $main_language . "'") or die("Stock_status: " . mysql_error());
if ($cat_res) {
    while($field = mysql_fetch_assoc($stock_res)) {
        $STOCK_MSG[$field['stock_status_id']] = $field['name'];
    }
}
 
######################################################################
 
 
##### Extract products from database ###############################################
 
// Build on stock condition
$on_stock_cond = ($on_stock_only == "on") ? "AND " . DB_PREFIX . "product.quantity > 0" : "";
 
// Add upc field
$upc_field = ($add_gtin == "on") ? DB_PREFIX . "product.upc," : "";
 
if ($show_description == "limited") {
    $description_field = "SUBSTRING(" . DB_PREFIX . "product_description.description, 1,500) AS prod_desc";
}
elseif($show_description == "on") {
    $description_field = DB_PREFIX . "product_description.description AS prod_desc";
}
else {
    $description_field = "''";
}
 
if ($oc_version == "1.4") {
   
    // Get product data
    $qry = "SELECT " . DB_PREFIX . "product_to_category.category_id, " . DB_PREFIX . "manufacturer.name as prod_manufacturer, " . DB_PREFIX . "product.model as prod_model, " . DB_PREFIX . "product.product_id as prod_id, " . DB_PREFIX . "product.tax_class_id, " . DB_PREFIX . "product_description.name as prod_name, " . $description_field . ", " . DB_PREFIX . "product.image as prod_image, " . DB_PREFIX . "product.price as prod_price, " . DB_PREFIX . "tax_rate.rate, " . DB_PREFIX . "product.stock_status_id, " . $upc_field . DB_PREFIX . "product.quantity
    FROM " . DB_PREFIX . "product
    LEFT JOIN " . DB_PREFIX . "product_description ON (" . DB_PREFIX . "product.product_id = " . DB_PREFIX . "product_description.product_id AND " . DB_PREFIX . "product_description.language_id = " . $main_language . ")
    LEFT JOIN " . DB_PREFIX . "manufacturer ON " . DB_PREFIX . "product.manufacturer_id = " . DB_PREFIX . "manufacturer.manufacturer_id
    LEFT JOIN " . DB_PREFIX . "product_to_category ON " . DB_PREFIX . "product.product_id = " . DB_PREFIX . "product_to_category.product_id
    LEFT JOIN " . DB_PREFIX . "tax_rate ON " . DB_PREFIX . "product.tax_class_id = " . DB_PREFIX . "tax_rate.tax_class_id
    WHERE " . DB_PREFIX . "product.status = '1' " . $on_stock_cond . "
    ORDER BY " . DB_PREFIX . "product.product_id ASC, " . DB_PREFIX . "product_to_category.category_id DESC";
}
else {
   
    // Get product data
    $qry = "SELECT " . DB_PREFIX . "product_to_category.category_id, " . DB_PREFIX . "manufacturer.name as prod_manufacturer, " . DB_PREFIX . "product.model as prod_model, " . DB_PREFIX . "product.product_id as prod_id, " . DB_PREFIX . "product.tax_class_id, " . DB_PREFIX . "product_description.name as prod_name, " . $description_field . ", " . DB_PREFIX . "product.image as prod_image, " . DB_PREFIX . "product.price as prod_price, " . DB_PREFIX . "product.stock_status_id, " . $upc_field . DB_PREFIX . "product.quantity
    FROM " . DB_PREFIX . "product
    LEFT JOIN " . DB_PREFIX . "product_description ON (" . DB_PREFIX . "product.product_id = " . DB_PREFIX . "product_description.product_id AND " . DB_PREFIX . "product_description.language_id = " . $main_language . ")
    LEFT JOIN " . DB_PREFIX . "manufacturer ON " . DB_PREFIX . "product.manufacturer_id = " . DB_PREFIX . "manufacturer.manufacturer_id
    LEFT JOIN " . DB_PREFIX . "product_to_category ON " . DB_PREFIX . "product.product_id = " . DB_PREFIX . "product_to_category.product_id
    WHERE " . DB_PREFIX . "product.status = '1' " . $on_stock_cond . "
    ORDER BY " . DB_PREFIX . "product.product_id ASC, " . DB_PREFIX . "product_to_category.category_id DESC";
}
 
$res_products = mysql_query($qry);
 
 
###################################################################
 
##### Print product data ####################################################
 
$current_id = 0;
$prod_count = 0;
 
if (!mysql_error()) {
    while ($row = mysql_fetch_assoc($res_products)) {
        // If we've sent this one, skip the rest - this is to ensure that we do not get duplicate products
       
        $prod_id = $row['prod_id'];
        if ($current_id == $prod_id) {
            continue;
        }
        else {
            $current_id = $prod_id;
        }
       
        // Get category name
        @$category_name = smfeed_get_full_cat($row['category_id'], $CAT_ARR);
       
        // Get manufacturer
        @$prod_manufacturer = $row['prod_manufacturer'];
 
        // Get product model
        $prod_model = $row['prod_model'];
 
        // Get name and description for product
        $prod_name = $row['prod_name'];
       
        // Limit description size
        if ($show_description == "limited") {
            $prod_desc = html_entity_decode($row['prod_desc'], ENT_QUOTES, 'UTF-8');
            $prod_desc = strip_tags($prod_desc);
            $prod_desc = substr(trim($prod_desc), 0, 300);
        }
        elseif ($show_description == "on") {
            $prod_desc = html_entity_decode($row['prod_desc'], ENT_QUOTES, 'UTF-8');
        }
        else {
            $prod_desc = "";
        }
       
        // Clean product name (new lines)
        $prod_name = str_replace("\n", "", strip_tags($prod_name));
        $prod_name = str_replace("\r", "", strip_tags($prod_name));
        $prod_name = str_replace("\t", " ", strip_tags($prod_name));
 
        // Clean product description (Replace new line with <BR>). In order to make sure the code does not contains other HTML code it might be a good ideea to strip_tags()
        $prod_desc = smfeed_replace_not_in_tags("\n", "<BR />", $prod_desc);
        $prod_desc = str_replace("\n", " ", $prod_desc);       
        $prod_desc = str_replace("\r", "", $prod_desc);
        $prod_desc = str_replace("\t", " ", $prod_desc);
 
        // Clean category product names and descriptions (separators)
        if ($datafeed_separator == "\t") {
            $category_name = str_replace("\t", " ", $category_name);
            // Continue... tabs were already removed
           
        }
        elseif ($datafeed_separator == "|") {
            $prod_name = str_replace("|", " ", strip_tags($prod_name));
            $prod_desc = str_replace("|", " ", $prod_desc);
            $category_name = str_replace("|", " ", $category_name);
        }
        else {
            print "Incorrect columns separator.";
            exit;
        }
 
        // Get product url
        $prod_url = smfeed_get_product_url($prod_id);
 
        // Add GA Tagging parameters to url
        if ($add_tagging == "on") {
            $and_param = (preg_match("/\?/", $prod_url)) ? "&" : "?";
            $prod_url = $prod_url . $and_param . $tagging_params;
        }
       
        // Get product image
        $prod_image = ($row['prod_image'] != "") ? smfeed_get_product_image($row['prod_image']) : "";
               
        // Get product price
        if (@$SPECIAL_PRICE[$prod_id]) {
            $prod_price = $tax->calculate($SPECIAL_PRICE[$prod_id], $row['tax_class_id'], $SETTING['config_tax']);
        }
        else {
            $prod_price = $tax->calculate($row['prod_price'], $row['tax_class_id'], $SETTING['config_tax']);
        }
 
        // Add VAT to prices
        if ($add_vat == "on") {
            $prod_price = $prod_price * $vat_value;
        }
           
        // Get conversion to wanted currency
        if ($add_currency == 1) {
            $prod_price = $prod_price * $currency_value;
        }
       
        // Fromat price
        $prod_price = number_format(round($prod_price, 2), 2, ".", "");
       
        // Build stock conditions
        if ($add_availability == "on") {
            if ($row['quantity'] > 0) {
                $availability = "In stock";
            }
            else {
                $availability = $STOCK_MSG[@$row['stock_status_id']];
            }
        }
        else {
            $availability = "";
        }
       
        // Add Shipping
        $shipping_value = ($add_shipping == "on") ? "" : "";
       
        // Add GTIN code
        $gtin = ($add_gtin == "on") ? @$row['upc'] : "";
       
        // Output the datafeed content
        // Category, Manufacturer, Model, ProdCode, ProdName, ProdDescription, ProdURL, ImageURL, Price, Currency, Shipping value, Availability, GTIN (UPC/EAN/ISBN)
       
        print
            $category_name . $datafeed_separator .
            $prod_manufacturer . $datafeed_separator .
            $prod_model . $datafeed_separator .
            $prod_id . $datafeed_separator .
            $prod_name . $datafeed_separator .
            $prod_desc . $datafeed_separator .
            $prod_url . $datafeed_separator .
            $prod_image . $datafeed_separator .
            $prod_price . $datafeed_separator .
            $datafeed_currency . $datafeed_separator .
            $shipping_value . $datafeed_separator .
            $availability . $datafeed_separator .
            $gtin . "\n";
       
        $prod_count ++;
       
        // Limit displayed products
        if ($limit > 0 && $prod_count >= $limit) {
            exit;
        }   
       
    }
}
else {
    print "<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>Query error: " . mysql_error() . "</BODY></HTML>";
}
 
###################################################################
 
##### Functions ########################################################
 
function smfeed_get_product_url($prod_id) {
    global $SEO_ARR, $sef;
   
    if ($sef == "on" && (@$SEO_ARR[$prod_id])) {
        return HTTP_SERVER . $SEO_ARR[$prod_id];
    }
    else {
        return HTTP_SERVER . "index.php?route=product/product&product_id=" . $prod_id;
    }
}
 
function smfeed_get_product_image ($prod_image) {
   
    $image_src = HTTP_IMAGE . $prod_image;   
    return $image_src;
   
}
 
function smfeed_replace_not_in_tags($find_str, $replace_str, $string) {
   
    $find = array($find_str);
    $replace = array($replace_str);   
    preg_match_all('#[^>]+(?=<)|[^>]+$#', $string, $matches, PREG_SET_ORDER);   
    foreach ($matches as $val) {   
        if (trim($val[0]) != "") {
            $string = str_replace($val[0], str_replace($find, $replace, $val[0]), $string);
        }
    }   
    return $string;
}
 
function smfeed_build_str_key($text){
   
    $text = str_replace(" ", "-", trim(smfeed_string_clean_search($text)));
    $text = rawurlencode(strtolower($text));
   
    $text = strtolower(smfeed_clean_accents($text));
   
    return $text;
}
 
// Function to get category with full path
function smfeed_get_full_cat($cat_id, $CATEGORY_ARR) {
 
    $item_arr = $CATEGORY_ARR[$cat_id];
    $cat_name = $item_arr['name'];
   
    while (sizeof($CATEGORY_ARR[$item_arr['parent_id']]) > 0 && is_array($CATEGORY_ARR[$item_arr['parent_id']]) ) {
       
        $cat_name = $CATEGORY_ARR[$item_arr['parent_id']]['name'] . " > " . $cat_name;       
        $item_arr = $CATEGORY_ARR[$item_arr['parent_id']];
    }
   
    // Strip html from category name
    $cat_name = smfeed_html_to_text($cat_name);
   
    return $cat_name;
}
 
function smfeed_html_to_text($string){
 
    $search = array (
        "'<script[^>]*?>.*?</script>'si",  // Strip out javascript
        "'<[\/\!]*?[^<>]*?>'si",  // Strip out html tags
        "'([\r\n])[\s]+'",  // Strip out white space
        "'&(quot|#34);'i",  // Replace html entities
        "'&(amp|#38);'i",
        "'&(lt|#60);'i",
        "'&(gt|#62);'i",
        "'&(nbsp|#160);'i",
        "'&(iexcl|#161);'i",
        "'&(cent|#162);'i",
        "'&(pound|#163);'i",
        "'&(copy|#169);'i",
        "'&(reg|#174);'i",
        "'&#8482;'i",
        "'&#149;'i",
        "'&#151;'i"
        );  // evaluate as php
   
    $replace = array (
        " ",
        " ",
        "\\1",
        "\"",
        "&",
        "<",
        ">",
        " ",
        "&iexcl;",
        "&cent;",
        "&pound;",
        "&copy;",
        "&reg;",
        "<sup><small>TM</small></sup>",
        "&bull;",
        "-",
        );
   
    $text = preg_replace ($search, $replace, $string);
    return $text;
   
}
 
// Clean accesnts
function smfeed_clean_accents($text){
 
    $search = array (
       
        "'%C4%99'", #e
        "'%C3%A8'", #e
        "'%C3%A9'", #e
        "'%C3%AA'", #e
        "'%C3%AB'", #e
        "'%C3%89'", #e
        "'%C3%88'", #E
        "'%C3%8A'", #E
       
        "'%C4%85'", #a
        "'%C3%A3'", #a
        "'%C3%A0'", #a
        "'%C3%A4'", #a
        "'%C3%A2'", #a   
        "'%C3%A1'", #a
        "'%C3%A5'", #a
        "'%C3%81'", #A
        "'%C3%82'", #A
        "'%C3%84'", #A
        "'%C3%85'", #A
        "'%C3%80'", #A
       
        "'%C4%87'", #c
        "'%C3%A7'", #c
        "'%C3%87'", #C
       
        "'%C5%9B'", #s
        "'%C5%A1'", #s
        "'%C5%A0'", #S
        "'%C5%9A'", #S
       
        "'%C3%B0'", #d
        "'%C3%B1'", #n
        "'%C3%BD'", #y
        "'%C4%9F'", #g
       
        "'%C4%B1'", #i
        "'%C3%AE'", #i
        "'%C3%AD'", #i
        "'%C3%AF'", #i
        "'%C3%AC'", #i
        "'%C3%8D'", #I
        "'%C3%8E'", #I
        "'%C4%B0'", #I
       
        "'%C5%82'", #l
       
        "'%C5%84'", #n
       
        "'%C3%BA'", #u
        "'%C3%BB'", #u
        "'%C3%B9'", #u
        "'%C3%BC'", #u
        "'%C5%B1'", #u
       
        "'%C3%9C'", #U
       
        "'%C3%B4'", #o
        "'%C3%B3'", #o
        "'%C3%91'", #o
        "'%C3%B6'", #o
        "'%C5%91'", #o
        "'%C3%B2'", #o
        "'%C3%B5'", #o
        "'%C3%93'", #O
        "'%C3%96'", #O
       
        "'%C3%9F'", #ss
        "'%C5%BC'", #z
        "'%C5%BA'", #z
        "'%C5%BB'", #Z
       
        "'%C3%A6'", #ae
        "'%C3%B8'", #oe
       
        "'%C2%AE'",
        "'%C2%B4'",
        "'%E2%84%A2'",
       
    );
   
    $replace = array (
       
        "e",
        "e",
        "e",
        "e",
        "e",
        "e",
        "E",
        "E",
       
        "a",
        "a",
        "a",
        "a",
        "a",
        "a",
        "a",
        "A",
        "A",
        "A",
        "A",
        "A",
       
        "c",
        "c",
        "C",
       
        "s",
        "s",
        "S",
        "S",
       
        "d",
        "n",
        "y",
        "g",
       
        "i",
        "i",
        "i",
        "i",
        "i",
        "I",
        "I",
        "I",
       
        "l",
       
        "n",
       
        "u",
        "u",
        "u",
        "u",
        "u",
       
        "U",
       
        "o",
        "o",
        "o",
        "o",
        "o",
        "o",
        "o",
        "O",
        "O",
       
        "ss",
        "z",
        "z",
        "Z",
       
        "ae",
        "oe",
       
        "",
        "",
        "",
       
    );
   
    $text = preg_replace($search, $replace, $text);
   
    return $text;
 
}
 
// Clean strings
function smfeed_string_clean_search($string){
   
    $trans = get_html_translation_table(HTML_ENTITIES);
    $trans = array_flip ($trans);
    $string = strtr($string, $trans);
   
    $search = array (
        "'&quot;'",
        "'&lt;'",
        "'&gt;'",
        "'%&pound;'",
        "'%&euro;'",
        "'-'",
        "'~'",
        "'!'",
        "'\?'",
        "'@'",
        "'#'",
        "'\\$'",
        "'%'",
        "'\^'",
        "'&'",
        "'\*'",
        "'\('",
        "'\)'",
        "'_'",
        "'\+'",
        "'='",
        "'\.'",
        "','",
        "'\''",
        "'\['",
        "'\]'",
        "'{'",
        "'}'",
        "'\|'",
        "'\"'",
        "':'",
        "';'",
        "'/'",
        "'\\\'",
        "'>'",
        "'<'",       
        "'[\r]+'",
        "'[\n]+'",
        "'[\t]+'",
        "'[\s]+'",
    );
   
    $replace = array (
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
    );
   
    $string = preg_replace($search, $replace, $string);
   
    return $string;
   
}
 
###################################################################
 
exit;
 
?>
 
  • Beğen
Tepkiler: İndependent
M

Mehmet GÜL

Katılım
20 Şubat 2012
Mesajlar
19
Çözümler
1
Tepkime puanı
1
Puanları
1
Konu hakkında Detaylı Bilgi Verirmisiniz. Bunu nasıl Kullancağız.
 
Network Destek

Network Destek

Yönetici
Opencart Uzmanı
Katılım
15 Ocak 2012
Mesajlar
46
Tepkime puanı
3
Puanları
10,001
Web sitesi
opencartfrm.com
http://www.shopmania.com.tr/ sitesinde ürünlerinizi fiyat kıyaslama yaptırabilirsiniz.
ucuzu, akakça tarzı fiyat karşılaştırma siteleri tarzında çalışmaktadır.
 
M

Mehmet GÜL

Katılım
20 Şubat 2012
Mesajlar
19
Çözümler
1
Tepkime puanı
1
Puanları
1
Yukarıdaki php xml olarak kaydedip sitemizemi atacağız?
 
Network Destek

Network Destek

Yönetici
Opencart Uzmanı
Katılım
15 Ocak 2012
Mesajlar
46
Tepkime puanı
3
Puanları
10,001
Web sitesi
opencartfrm.com
hayır php olarak kaydedip sitenizin ana dizinine atacaksınız. Daha sonra shopmania müşteri panelinizden datafeed doğrula yapacaksınız. Xml çalışacak ve ürünleriniz shopmania ya aktarılacak. Ürünlerinizin listelenmesi bir sonraki gün aktif olacaktır.
 

Yorum yapmak için giriş yapın veya Kayıt olun

Yorum yapabilmek için üye olmalısınız

Hesap oluştur

Forumumuzda bir hesap oluşturun. Çok kolay!

Giriş yap

Zaten bir hesabınız var mı? Buradan giriş yapın.

Konuyu Okuyanlar (Toplam: 0)
    🚀 OpenCart E-Ticaret Paketi şimdi PHP 8.3 ile güçlendi! Performans artışı ve yeni özelliklerle online satışınızı hızlandırın! Hızla İncele! ✖️