PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Gambio Import per Cronjob



micromouse
14.03.2017, 10:17
Hallo liebe Gemeinde,

ich habe mich ein wenig mit obigen Thema beschäftigt. Im Internet habe ich dazu auch nichts gefunden.
Wollte mir ein eigenes Script schreiben ... hat auch nicht funktioniert ... da anscheinend die Import-Funktionen "admin/includes/classes/import.php" nicht mit GX3 funktionieren.
Ich habe die Version GX3 3.1.3.0 ! Das Script kommt mit den Kategorien nicht klar (p.cat.0 usw. Kategoriepfad Gruppe1[x] > Gruppe2[x]).

import.php Debug aktiviert:


Array
(
[p_id] =>
[p_model] => 1212121
[p_stock] => 1000
[p_tpl] => standard.html
[p_sorting] => 0
[p_manufacturer] => 0
[p_fsk18] => 0
[p_priceNoTax] => 2500.0
[p_tax] => 1
[p_status] => 1
[p_weight] => 5.0000
[p_ean] => 121212
[p_disc] =>
[p_opttpl] => product_options_dropdown.html
[p_image] => xyz.jpg
[p_vpe] => 0
[p_vpe_status] => 0
[p_vpe_value] => 0.0000
[product_type] =>
[p_shipping] => 1
[p_startpage] => 0
[p_startpage_sort] => 0
[p_date_added] => 2017-02-18 19:11:50
[p_last_modified] =>
[p_date_available] => 1000-01-01 00:00:00
[p_ordered] => 0.0000
[nc_ultra_shipping_costs] => 0.0000
[gm_show_date_added] => 0
[gm_show_price_offer] => 1
[gm_show_weight] => 0
[gm_show_qty_info] => 1
[gm_price_status] => 0
[gm_min_order] => 1.0000
[gm_graduated_qty] => 1.0000
[gm_options_template] => product_options_dropdown.html
[code_isbn] =>
[code_upc] =>
[code_mpn] =>
[code_jan] =>
[brand_name] =>
[identifier_exists] =>
[gender] =>
[age_group] =>
[expiration_date] =>
[p_priceNoTax.0] =>
[p_priceNoTax.1] =>
[p_priceNoTax.2] =>
[p_priceNoTax.3] =>
[p_groupAcc.] =>
[p_groupAcc.0] =>
[p_groupAcc.1] =>
[p_groupAcc.2] =>
[p_groupAcc.3] =>
[p_image.1] =>
[p_image.2] =>
[p_image.3] =>
[p_image.4] =>
[p_image.5] =>
[p_image.6] =>
[p_image.7] =>
[p_name.de] => xxxx
[p_desc.de] =>
[p_shortdesc.de] =>
[p_checkout_information.de] =>
[p_meta_title.de] =>
[p_meta_desc.de] =>
[p_meta_key.de] =>
[p_keywords.de] =>
[p_url.de] =>
[gm_url_keywords.de] => xxxx
[af[1]..de] =>
[af[2]..de] =>
[af[3]..de] =>
[af[4]..de] =>
[af[5]..de] =>
[p_name.en] => Testartikel
[p_desc.en] =>
[p_shortdesc.en] =>
[p_checkout_information.en] =>
[p_meta_title.en] =>
[p_meta_desc.en] =>
[p_meta_key.en] =>
[p_keywords.en] =>
[p_url.en] =>
[gm_url_keywords.en] => Testartikel
[af[1]..en] =>
[af[2]..en] =>
[af[3]..en] =>
[af[4]..en] =>
[af[5]..en] =>
[p_cat.0] => Kategorie0
[p_cat.1] =>
[p_cat.2] =>
[p_cat.3] =>
[p_cat.4] =>
[p_cat.5] =>
[google_export_availability] => auf Lager
[google_export_condition] => Neu
[google_category] =>
)
USER ERROR(256): "SQL Error"

Oder sollte ich mich mit folgenden beschäftigen "system\classes\csv\CSVImportFunctionLibrary.inc.ph p" bzw. gibts sowasschon fertig ?

Vielleicht habt Ihr ein paar gute Ideen !

LG
Micromouse

KlausK
14.03.2017, 19:29
Mir ist nicht klar was du überhaupt machen willst? :confused:

micromouse
14.03.2017, 20:23
Hallo Klaus, ich möchte über einen Link oder per Cronjob automatisch Daten importieren. Die Daten werden fertig in das Import-Verzeichnis gestellt.
Folgendes Script sollte funktionieren, tut es aber nicht ... Fehler: SQL-Error. Kategorie ist vorhanden. Manueller Import, gleiches Import-File, kein Problem.


<?php
/* --------------------------------------------------------------
csv_backend.php 2015-09-28 gm
Gambio GmbH
http://www.gambio.de
Copyright (c) 2015 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]

IMPORTANT! THIS FILE IS DEPRECATED AND WILL BE REPLACED IN THE FUTURE.
MODIFY IT ONLY FOR FIXES. DO NOT APPEND IT WITH NEW FEATURES, USE THE
NEW GX-ENGINE LIBRARIES INSTEAD.
--------------------------------------------------------------

based on:
(c) 2000-2001 The Exchange Project (earlier name of osCommerce)
(c) 2002-2003 osCommercecoding standards (a typical file) www.oscommerce.com
(c) 2003 XT-Commerce - community made shopping http://www.xt-commerce.com ($Id: csv_backend.php 1030 2005-07-14 20:22:32Z novalis $)

Released under the GNU General Public License
--------------------------------------------------------------*/

$import_file = 'ImportGambio.csv';

// tell modified shop code, we have a secure access
define('_VALID_XTC', true);
// tell import class our delimeter and textsign

require('includes/application_top.php');
require('admin/includes/classes/import.php');
require('inc/xtc_format_filesize.inc.php');
require('inc/xtc_get_customers_statuses.inc.php');
/*
echo "DIR: " . DIR_FS_CATALOG . "<br>";
echo "CSV_SEPERATOR: " . CSV_SEPERATOR . "<br>";
echo "CSV_TEXTSIGN: " . CSV_TEXTSIGN . "<br>";
echo "import_file: " . $import_file . "<br>";
echo "<br><br><br>";
/*
require_once(DIR_FS_INC . 'xtc_format_filesize.inc.php');
*/
// make a connection to the database... now
xtc_db_connect() or die('Unable to connect to database server!');

// define the database table names used in the project
define('TABLE_CATEGORIES', 'categories');
define('TABLE_CATEGORIES_DESCRIPTION', 'categories_description');
define('TABLE_CONFIGURATION', 'configuration');
define('TABLE_CUSTOMERS_STATUS', 'customers_status');
define('TABLE_LANGUAGES', 'languages');
define('TABLE_MANUFACTURERS', 'manufacturers');
define('TABLE_MANUFACTURERS_INFO', 'manufacturers_info');
define('TABLE_PRODUCTS', 'products');
define('TABLE_PRODUCTS_ATTRIBUTES', 'products_attributes');
define('TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD', 'products_attributes_download');
define('TABLE_PRODUCTS_CONTENT','products_content' );
define('TABLE_PRODUCTS_DESCRIPTION', 'products_description');
define('TABLE_PRODUCTS_NOTIFICATIONS', 'products_notifications');
define('TABLE_PRODUCTS_IMAGES', 'products_images');
define('TABLE_PRODUCTS_OPTIONS', 'products_options');
define('TABLE_PRODUCTS_OPTIONS_VALUES', 'products_options_values');
define('TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_ OPTIONS', 'products_options_values_to_products_options');
define('TABLE_PRODUCTS_TO_CATEGORIES', 'products_to_categories');
define('TABLE_REVIEWS', 'reviews');
define('TABLE_REVIEWS_DESCRIPTION', 'reviews_description');

// set application wide parameters
$configuration_query = xtc_db_query("select configuration_key as cfgKey, configuration_value as cfgValue from " . TABLE_CONFIGURATION . " where configuration_group_id = '20' order by sort_order");
//$configuration_query = xtc_db_query("select configuration_key,configuration_id, configuration_value, use_function,set_function from " . TABLE_CONFIGURATION . " where configuration_group_id = '20' order by sort_order");
while ($configuration = xtc_db_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);
echo "conf: " . $configuration['cfgKey'] . $configuration['cfgValue'];
}



$handler = new xtcImport($import_file);
$mapping=$handler->map_file($handler->generate_map());
$import=$handler->import($mapping);

if ($import)
{
if($import[0])
{
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="messageStackSuccess">';
if (isset($import[0]['prod_new'])) echo 'Neue Artikel:'.$import[0]['prod_new'].'<br />';
if (isset($import[0]['cat_new'])) echo 'Neue Kategorien:'.$import[0]['cat_new'].'<br />';
if (isset($import[0]['prod_upd'])) echo 'Aktualisierte Artikel:'.$import[0]['prod_upd'].'<br />';
if (isset($import[0]['cat_upd'])) echo 'Aktualisierte Kategorien:'.$import[0]['cat_upd'].'<br />';
if (isset($import[0]['cat_touched'])) echo 'Betroffene Kategorien:'.$import[0]['cat_touched'].'<br />';
if (isset($import[2])) echo $import[2];
echo '</td></tr></table>';
}
/*
if (isset($import[1]) && $import[1][0]!='')
{
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="messageStackError">';
for ($i=0;$i<count($import[1]);$i++)
{
echo $import[1][$i].'<br />';
}
echo '</td></tr></table>';
}
*/
}

for ($i=0;$i<count($import[1]);$i++)
{
echo $import[1][$i].'<br />';
}


?>


Error-File:


2017-03-14 16:44:25 (b2d89926b4a11ab8a1279a5890dccef7) USER ERROR(256): "SQL Error" in /var/www/web456/html/testshop.neiflex.at/inc/xtc_db_error.inc.php:24

#5 File: /var/www/web456/html/testshop.neiflex.at/inc/xtc_db_error.inc.php:24

Code:
│ line 22: $coo_logger = LogControl::get_instance();
│ line 23: $coo_logger->notice($p_error, 'error_handler', 'errors', 'notice', 'SQL ERROR', $p_errno, 'Query:' . "\r\n" . trim($p_query));
├─ line 24: trigger_error('SQL Error', E_USER_ERROR);
│ line 25: }
#4 File: /var/www/web456/html/testshop.neiflex.at/inc/xtc_db_query.inc.php:69

Code:
│ line 67: {
│ line 68: # execute query
├─ line 69: $result = mysqli_query( $$link, $p_query) or xtc_db_error($p_query, ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false)), ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
│ line 70:
│ line 71: # save result to cache

#3 File: /var/www/web456/html/testshop.neiflex.at/inc/xtc_db_perform.inc.php:147

Code:
│ line 145: if(empty($t_sql) == false)
│ line 146: {
├─ line 147: $t_result = xtc_db_query($t_sql, $p_link);
│ line 148: }
│ line 149:

#2 File: /var/www/web456/html/testshop.neiflex.at/admin/includes/classes/import.php:614

Code:
│ line 612: {
│ line 613: $insert_array = array('group_permission_'.$this->Groups[$key]['id'] => $dataArray['p_groupAcc.'.$this->Groups[$key]['id']]);
├─ line 614: xtc_db_perform(TABLE_PRODUCTS, $insert_array, 'update', 'products_id = \''.$products_id.'\'');
│ line 615: }
│ line 616: }

#1 File: /var/www/web456/html/testshop.neiflex.at/admin/includes/classes/import.php:287

Code:
│ line 285: $t_rebuild_all_products_to_categories = true;
│ line 286: if($this->checkModel($line_data['p_model'])){
├─ line 287: $this->insertProduct($line_data, 'update', true, 'p_model');
│ line 288: }
│ line 289: else{

#0 File: /var/www/web456/html/testshop.neiflex.at/cron_import_new.php:82

Code:
│ line 80: $handler = new xtcImport($import_file);
│ line 81: $mapping=$handler->map_file($handler->generate_map());
├─ line 82: $import=$handler->import($mapping);
│ line 83:
│ line 84: if ($import)

Request: GET /cron_import_new.php
- duration: ~3579ms
- server: Apache
- server address: 109.237.140.6
- user agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
- remote address: b2d89926b4a11ab8a1279a5890dccef7

Session:
- tpl: Honeygrid
- MOBILE_ACTIVE: false
- language: german
- languages_id: 2
- language_charset: utf-8
- language_code: de
- currency: EUR
- customers_status: Array
(
[customers_status_id] => 1
[customers_status_name] => Gast
[customers_status_image] => guest_status.gif
[customers_status_discount] => 0.00
[customers_status_public] => 0
[customers_status_min_order] => 0
[customers_status_max_order] => 0
[customers_status_ot_discount_flag] => 0
[customers_status_ot_discount] => 0.00
[customers_status_graduated_prices] => 1
[customers_status_show_price] => 1
[customers_status_show_price_tax] => 1
[customers_status_add_tax_ot] => 1
[customers_status_payment_unallowed] =>
[customers_status_shipping_unallowed] =>
[customers_status_discount_attributes] => 0
[customers_fsk18] => 1
[customers_fsk18_display] => 1
[customers_status_write_reviews] => 0
[customers_status_read_reviews] => 1
)

- cart: shoppingCart Object
(
[contents] => Array
(
)

[total] => 0
[weight] => 0
[content_type] =>
)

- wishList: wishList Object
(
[contents] => Array
(
)

[total] => 0
[weight] => 0
[content_type] =>
)

- customer_id: ### Session entry not present ###
- payment: ### Session entry not present ###
- shipping: ### Session entry not present ###
- cartID: ### Session entry not present ###
- sendto: ### Session entry not present ###
- billto: ### Session entry not present ###

KlausK
15.03.2017, 14:33
Das geht nicht so ohne Weiteres. Mir ist da auch leider nichts Fertiges bekannt. Ich brauche soetwas eigentlich auch noch!
Das Shopsystem lässt ja nur dem System bekannte User schalten und walten. Wenn jetzt aber irgendein root, www-data, oder wer auch immer, mittels Cron versucht eine Funktion auszuführen, dann sagt das Shop-System "is nich". Und das ist auch richtig so!
Du müsstest dir im Grunde ein Script bauen, das sich quasi zunächst am Shop anmeldet um dann einen Token zu erhalten mit dem dann weitere Funktionen im Shop gestartet werden können.
M.E. ist es aber einfacher die DB direkt via Script zu bearbeiten. Meistens geht es ja auch nur um einfache Dinge wie z.B. Lagerbestand anpassen.

micromouse
15.03.2017, 20:19
Auf das bin ich auch schon gekommen ... Security Token ...


$configuration_query = xtc_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION . '');
while ($configuration = xtc_db_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);

könnte sowas gemeint sein ... kenne mich mit dem System einfach noch zu wenig aus ... müsste mich tiefer in die Materie einarbeiten ...