Configurare questi comparatori prezzi

Postate qui discussioni di carattere generale riguardo a problemi di installazione e configurazione di osCommerce

Moderatore: mod Generali

Rispondi
3dstudiomax
membro Veteran
membro Veteran
Messaggi: 520
Iscritto il: 24/06/2008, 19:45

Configurare questi comparatori prezzi

Messaggio da 3dstudiomax »

Ragazzi riscontro difficoltà a configurare questi due comparatori prezzi:

CIAO

Codice: Seleziona tutto

$path_catalog = "http://www.sito.est/";

# Once all is set up you need to check the result and make sure the output is correct
# Point the browser to http://www.example.com/catalog/datafeed.php and look into the source code of the out put
# What you need to see is something like this
# Category | Brand | MPN | Merchant Offer Id | Product Name | Product Description | Product URL | Product Image URL | Product Price | Currency

##### Avoid any modifications below this line #####

// Datafeed specific settings
if (isset($_GET['separator']))
    $datafeed_separator = $_GET['separator'];
else
    $datafeed_separator = ",";

if (isset($_GET['enclosure']))
    $datafeed_enclosure = $_GET['enclosure'];
else
    $datafeed_enclosure = '"';

if (isset($_GET['lineend']))
    $line_separator = $_GET['lineend'];
else
    $line_separator = "\n";

$strip_newline_in_description = true;

// Include required files
if(!file_exists($path_catalog . "/includes/application_top.php")) {
    exit('Please ensure that datafeed.php is in the catalog directory, or make sure the path to the catalog directory is defined corectly above in $catalog_path variable');
}
else {
    require($path_catalog . "/includes/application_top.php");
}

$already_sent = array();

// Detect default currency
$query_currency = tep_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'DEFAULT_CURRENCY'");
$row_currency = tep_db_fetch_array( $query_currency );

// Detect default language code
$query_language_code = tep_db_query("SELECT configuration_value FROM "  TABLE_CONFIGURATION . " WHERE configuration_key = 'DEFAULT_LANGUAGE'");
$row_language_code = tep_db_fetch_array( $query_language_code );

if (isset($_GET['language_code']))
    $row_language_code['configuration_value'] = $_GET['language_code'];

// Detect default language ID
$query_language_id = tep_db_query("SELECT languages_id FROM " . TABLE_LANGUAGES . " WHERE code = '" . $row_language_code['configuration_value'] . "'");
$row_language_id = tep_db_fetch_array( $query_language_id );

if (isset($_GET['language_id']))
    $row_language_id['languages_id'] = $_GET['language_id'];

// Grab the products
$products_query = tep_db_query("SELECT
manuf.manufacturers_name AS manufacturer,
prd.products_quantity AS quantity,
prd.products_date_available AS availability_date,
prd.products_id AS id,
prd.products_id AS mpc,
prd.products_model AS mpn,
prdsc.products_name AS name,
prdsc.products_description AS description,
prd.products_price AS price,
prd.products_image,

IF(catdescparent2.categories_name!='',
CONCAT_WS( ' > ' , catdescparent2.categories_name , CONCAT_WS( ' > ' , catdescparent.categories_name , catdesccurrent.categories_name )),
CONCAT_WS( ' > ' , catdescparent.categories_name , catdesccurrent.categories_name )
)
AS category

FROM (" . TABLE_CATEGORIES . " ,
" . TABLE_PRODUCTS . " prd,
" . TABLE_PRODUCTS_DESCRIPTION . " AS prdsc,
" . TABLE_CATEGORIES_DESCRIPTION . " AS catdesccurrent,
" . TABLE_PRODUCTS_TO_CATEGORIES . " AS prdtocat)
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent on ( catdescparent.categories_id = " . TABLE_CATEGORIES . ".parent_id AND catdescparent.language_id = '" . $row_language_id['languages_id'] . "' )
LEFT JOIN " . TABLE_CATEGORIES . " AS cat2 on ( cat2.categories_id = "  TABLE_CATEGORIES . ".parent_id )
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent2 on ( catdescparent2.categories_id = cat2.parent_id AND catdescparent2.language_id = '" . $row_language_id['languages_id'] . "' )
LEFT JOIN " . TABLE_MANUFACTURERS . " AS manuf ON ( manuf.manufacturers_id = prd.manufacturers_id )
WHERE
( prd.products_id = prdsc.products_id AND prdsc.language_id = '" . $row_language_id['languages_id'] . "' )
AND prd.products_id = prdtocat.products_id
AND prdtocat.categories_id = " . TABLE_CATEGORIES . ".categories_id
AND ( catdesccurrent.categories_id = " . TABLE_CATEGORIES . ".categories_id AND catdesccurrent.language_id = '" . $row_language_id['languages_id'] . "' )
AND prd.products_status != 0");

// Check for any applicable specials for the corresponding products_id
$specials_query = tep_db_query("SELECT
" . TABLE_SPECIALS . ".products_id AS idS,
FORMAT(" . TABLE_SPECIALS . ".specials_new_products_price, 2) AS priceS
FROM
" . TABLE_SPECIALS . ",
" . TABLE_PRODUCTS . "
WHERE
" . TABLE_SPECIALS . ".products_id = " . TABLE_PRODUCTS . ".products_id
AND " . TABLE_SPECIALS . ".status != 0
AND " . TABLE_PRODUCTS . ".products_status != 0");

while( $row_s = tep_db_fetch_array( $specials_query ) )
{
    foreach ($row_s as $i=>$v) {
        $SPECIALS[$row_s['idS']][$i] = $v;
    }
}

header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"offers.csv\"");

// print header
print
encloseValue('Category',$datafeed_enclosure) . $datafeed_separator .
encloseValue('Brand',$datafeed_enclosure) . $datafeed_separator .
encloseValue('MPN',$datafeed_enclosure) . $datafeed_separator .
encloseValue('Merchant Offer Id',$datafeed_enclosure) . $datafeed_separator .
encloseValue('Product Name',$datafeed_enclosure) . $datafeed_separator .
encloseValue('Product Description',$datafeed_enclosure) . $datafeed_separator .
encloseValue('Product URL',$datafeed_enclosure) . $datafeed_separator .
encloseValue('Product Image URL',$datafeed_enclosure) . $datafeed_separator .
encloseValue('Product Price',$datafeed_enclosure) . $datafeed_separator 
encloseValue('Currency',$datafeed_enclosure) . $datafeed_separator .
encloseValue('Quantity',$datafeed_enclosure) .  $datafeed_separator .
encloseValue('Available from',$datafeed_enclosure) . $line_separator;


// Print the products
while( $row = tep_db_fetch_array( $products_query ) )
{
    // If we've sent this one, skip the rest - this is to ensure that we do not get duplicate products
    if ($already_sent[$row['mpc']] == 1) continue;

    $row['product_url'] = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $row['id'], 'NONSSL', false);
    if($row['products_image'])
    {
        $row['image_url'] = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $row['products_image'];
    }

    // Reset the products price to our special price if there is one for this product
    if( $SPECIALS[$row['id']]['idS'] ){
        $row['price'] = $SPECIALS[$row['id']]['priceS'];
    }

    // Clean product name (new lines)
    $row['name'] = str_replace("\n", " ", $row['name']);

    // remove \r from description
    $row['description'] = str_replace("\r", "", $row['description']);
    // replace space entity with actual space
    $row['description'] = str_replace(" ", " ", $row['description']);
    // need a space between \n and " if both are in a cell, otherwise behaviour is wrong in apps
    $row['description'] = str_replace("\n\"", "\n \"", $row['description']);
    // remove html tags
    $row['description'] = strip_tags($row['description']);
    // remove extra spaces
    $row['description'] = preg_replace("/\s+/", " ", $row['description']);

    if ($strip_newline_in_description)
        $row['description'] = str_replace("\n", ' ', $row['description']);

    // Clean product names and descriptions (separators)
    if ($datafeed_separator == "\t") {
        $row['name'] = str_replace("\t", " ", strip_tags($row['name']));
        $row['description'] = str_replace("\t", " ", $row['description']);
    }
    elseif ($datafeed_separator == "|") {
        $row['name'] = str_replace("|", " ", strip_tags($row['name']));
        $row['description'] = str_replace("|", " ", $row['description']);
    }

    if ($datafeed_enclosure == '"') {
        $row['name'] = str_replace('"', '""', strip_tags($row['name']));
        $row['description'] = str_replace('"', '""', $row['description']);
    }
    elseif ($datafeed_enclosure == "'") {
        $row['name'] = str_replace("'", "\\'", strip_tags($row['name']));
        $row['description'] = str_replace("'", "\\'", $row['description']);
    }
    // Output the datafeed content
    print
    encloseValue($row['category'],$datafeed_enclosure) . $datafeed_separator .
    encloseValue($row['manufacturer'],$datafeed_enclosure) . $datafeed_separator .
    encloseValue($row['mpn'],$datafeed_enclosure) . $datafeed_separator 
    encloseValue($row['mpc'],$datafeed_enclosure) . $datafeed_separator 
    encloseValue($row['name'],$datafeed_enclosure) . $datafeed_separator 
    encloseValue($row['description'],$datafeed_enclosure) . $datafeed_separator .
    encloseValue($row['product_url'],$datafeed_enclosure) . $datafeed_separator .
    encloseValue($row['image_url'],$datafeed_enclosure) . $datafeed_separator .
    encloseValue($row['price'],$datafeed_enclosure) . $datafeed_separator .
    encloseValue($row_currency['configuration_value'],$datafeed_enclosure) . $datafeed_separator .
    encloseValue($row['quantity'],$datafeed_enclosure) . $datafeed_separator .
    encloseValue($row['availability_date'],$datafeed_enclosure) . $line_separator;

    $already_sent[$row['mpc']] = 1;
}

function encloseValue($strVal, $strEncloseChar) {
    return $strEncloseChar . $strVal . $strEncloseChar;
}

exit;

?>

Shopmania

Codice: Seleziona tutto

<?php

// Database access info
$db_location = "";
$db_name = "";
$db_username = "";
$db_password = "";

// Datafeed specific settings
$datafeed_separator = "|"; // Possible options are \t or |
$datafeed_currency = "EUR"; // Please make sure that you are using the corect currency code. Possible values are EUR, USD

// Connect to the database
$conn = @mysql_connect($db_location, $db_username, $db_password);
if (mysql_error()) {
	print "Connection error. Please check the connection settings. Bye bye...";
	exit;
}
// Select database to use
else {
	@mysql_select_db($db_name, $conn);
	if (mysql_error()) {
		print "Connection error. Please check the connection settings. Bye bye...";
		exit;
	}
}

$prod_table = ""; // products table
$cat_table = ""; // categories table

// Query database for extracting data. It might be needed to left join the categories table for extracting the category name
$q = "SELECT $cat_table.name, $prod_table.manufacturer, $prod_table.model, $prod_table.id, $prod_table.name, $prod_table.desc, $prod_table.image, $prod_table.price FROM $prod_table
LEFT JOIN $cat_table ON $prod_table.cat_id = $cat_table.id
WHERE $prod_table.status = 'active'";
$r = @mysql_query($q);

// There are no errors so we can continue
if (!mysql_error()) {

	while (list($cat_name, $prod_manufacturer, $prod_model, $prod_id, $prod_name, $prod_desc, $prod_image, $prod_price) = mysql_fetch_row($r)) {		
		// Clean product name (new lines)
		$prod_name = str_replace("\n", "", 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 = replace_not_in_tags("\n", "<BR />", $prod_desc);
		$prod_desc = str_replace("\n", " ", $prod_desc);
		$prod_desc = str_replace("\r", "", $prod_desc);
		
		// Clean product names and descriptions (separators)
		if ($datafeed_separator == "\t") {
			$prod_name = str_replace("\t", " ", strip_tags($prod_name));
			$prod_desc = str_replace("\t", " ", $prod_desc);
		}
		elseif ($datafeed_separator == "|") {
			$prod_name = str_replace("|", " ", strip_tags($prod_name));
			$prod_desc = str_replace("|", " ", $prod_desc);
		}
		else {
			print "Incorrect columns separator.";
			exit;			
		}
		
		$prod_url = function_to_get_product_url($prod_id);		
		$prod_image = function_to_get_product_image($prod_image);		
		
		// Here you can overwrite the default currency if your products are listed with different currencies
		// $datafeed_currency = $prod_currency
		
		// Required fields are: category name, merchant product ID, product name, product URL, product price
		// For the product model you should only use the manufacturer code, ISBN code or UPC code - If you are not sure about a field please leave it empty
		
		// Strip html from category name
		$cat_name = html_to_text($cat_name);
		
		// Output the datafeed content
		print  
		$cat_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 . "\n";
	}

}
else {
	print "Query error: " . mysql_error();
}

// Function to return the Product URL based on your product ID
function function_to_get_product_url($prod_id){	
	return "http://www.sito.est/product.php?id=" . $prod_id;
}

// Function to return the Product Image based on your product image or optionally Product ID
function function_to_get_product_image($prod_image){	
	return "http://www.sito.est/product_images/" . $prod_image . ".jpg";	
}

function 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",
		"'™'i",
		"'&#149;'i",
		"'&#151;'i",
		"'&#(\d+);'e"
		);  // evaluate as php
	
	$replace = array (
		" ",
		" ",
		"\\1",
		"\"",
		"&",
		"<",
		">",
		" ",
		"¡",
		"¢",
		"£",
		"©",
		"®",
		"<sup><small>TM</small></sup>",
		"•",
		"-",
		"uchr(\\1)"
		);
	
	$text = preg_replace ($search, $replace, $string);
	return $text;
	
}

function 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;
}

?>
Avatar utente
xnetus
membro Senior
membro Senior
Messaggi: 371
Iscritto il: 08/09/2008, 17:50
Contatta:

Re: Configurare questi comparatori prezzi

Messaggio da xnetus »

Ciao,
precisamente qual'è il tuo problema?
Assistenza osCommerce e Realizzazione Moduli!
Solo una piattaforma ben gestita può garantirti dei benefici notevoli. Contattaci e scopri quali sono le potenzialità del tuo business.
(email: info@xnetus.net)
Scopri il servizio...
deltabiri
membro Veteran
membro Veteran
Messaggi: 549
Iscritto il: 28/03/2007, 9:53
Località: IMOLA
Contatta:

Re: Configurare questi comparatori prezzi

Messaggio da deltabiri »

Codice: Seleziona tutto

$path_catalog = "http://www.sito.est/";
devi inserire il nome del tuo sito

Codice: Seleziona tutto

// Database access info
$db_location = "";
$db_name = "";
$db_username = "";
$db_password = "";
qui invece i dati del database

p.s. aspetta che qualcuno confermi quello che ho scritto :mrgreen:
>> visitate il mio sito 2.2 http://WWW.TENTAZIONISHOP.IT
>> visitate il mio sito 2.3 http://WWW.INTIMOCLICK.IT
3dstudiomax
membro Veteran
membro Veteran
Messaggi: 520
Iscritto il: 24/06/2008, 19:45

Re: Configurare questi comparatori prezzi

Messaggio da 3dstudiomax »

Shopmania mi da questo errore:

Codice: Seleziona tutto

Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' .manufacturer, .model, .id, .name, .desc, .image, .price FROM LEFT JOIN ON .c' at line 1

Mentre Ciao

Codice: Seleziona tutto

Parse error: syntax error, unexpected T_STRING in /web/htdocs/www.sito.org/home/datafeed_os.php on line 48
3dstudiomax
membro Veteran
membro Veteran
Messaggi: 520
Iscritto il: 24/06/2008, 19:45

Re: Configurare questi comparatori prezzi

Messaggio da 3dstudiomax »

nessun suggerimento ?
Rispondi