avstudnitz / AvS_FastSimpleImport

Wrapper for Magento ImportExport functionality, which imports products and customers from arrays
308 stars 146 forks source link

Problem importation customer #259

Open pigorg opened 8 years ago

pigorg commented 8 years ago

Hi.

I use magento 1.9.2 I must import each 12/24 hours. I need to syncronize magento db with another software management.

If entity_id exist I need to update if entity_id not exist i need to create a new customer

i tryed to insert a new customer with your plugin but

Fatal error: Call to a member function getErrorMessages() on a non-object in /srv/www/vhosts/www.alessandro.com/app/code/community/AvS/FastSimpleImport/Model/Import.php on line 498

i send you my script?

what the problem? i created a new directory under the root for my scripts

thanks Alessandro

avstudnitz commented 8 years ago

Yes, please publish the important parts of your script.

pigorg commented 8 years ago

<?php require_once("../app/Mage.php"); require_once("gestione-tabelle.php"); require_once("funzioni.php");

error_reporting(E_ALL); ini_set('display_errors', 1); Mage::setIsDeveloperMode(true);

function getUniqueCode($length = "") { $code = md5(uniqid(rand(), true)); if ($length != "") return substr($code, 0, $length); else return $code; }

umask(0); Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

ini_set('max_execution_time', 600);

// connection in another db $con = mssql_connect($host_interscambio, $username_interscambio, $password_interscambio) or die('Errore connessione') ;

mssql_select_db($database_interscambio) or die('Errore selezione database');

$query = mssql_query("select Ditta, Tipo_CF, Cod_CLIFOR, Ragione_Sociale, Cod_Stato, P_IVA, COD_FISC, Indirizzo, CAP, Citta, Provincia, Tel_1, Tel_2, Fax, Cellulare, Mail, CliFor_Bloccato, Cod_Pag, Cod_IVA, Cod_Agente, Cod_Macrocateg, ID_Web, User_web, Pwd_web

from GES_DBOFFICE.dbo.TSF_V_KY_CLI_ANAGR");

if (!mssql_num_rows($query)) { echo 'No records found'; } else {

while ($row = mssql_fetch_assoc($query)) { //echo $row['Tipo_CF'].$row['Cod_CLIFOR'].$row['Ragione_Sociale'] . $row['Cod_Stato'] . $row['P_IVA'] . $row['COD_FISC'] . $row['Indirizzo']. '
';

$email=$row['Mail']; $ragione_sociale=$row['Ragione_Sociale']; $codice_cliente=$row['Cod_CLIFOR']; $nome="----"; $cognome="-----"; $middlename="----"; $partita_iva=$row['P_IVA']; $indirizzo=$row['Indirizzo']; $citta=$row['Citta']; $cap=$row['CAP']; $telefono=$row['Tel_1']; $fax=$row['Fax'];

$rowData = array( array( //'otherdb_customer_id' => '$codice_cliente', 'store_id' => '$store_id', '_website' => '$website', '_store' => '$vista', 'email' => '$email', 'group_id' => '$gruppo_id', 'disable_auto_group_change' => 0, 'firstname' => '$nome', 'middlename' => '$middlename', 'lastname' => '$cognome', 'taxvat' => '$partita_iva', '_address_firstname' => '$nome', '_address_middlename' => '', '_address_lastname' => '$cognome', '_address_street' => '$indirizzo', '_address_city' => '$citta', '_address_country_id' => 'IT', '_address_postcode' => '$cap', '_address_telephone' => '$telefono', '_address_company' => '$ragione_sociale', '_address_fax' => '$fax', '_address_defaultbilling' => 1, '_address_defaultshipping'=> 0, ),

array(
    'email' => null,
    '_website' => null,
    '_address_firstname' => 'John',
    '_address_lastname' => 'Doe',
    '_address_street' => 'Countryside 99',
    '_address_postcode' => '98765',
    '_address_city' => 'Cape Cod',
    '_address_country_id' => 'US',
    '_address_telephone' => '+1 9876 54321',
    '_address_default_billing_' => 0,
    '_address_default_shipping_' => 1,
),

);

$import = Mage::getModel('fastsimpleimport/import'); try { $import->processCustomerImport($data); } catch (Exception $e) { echo $import->getErrorMessages(); }

} }

my script is into /sincro dir near root thanks a lot! Ale

pigorg commented 8 years ago

i modified the row return $this->getEntityAdapter()->getErrorMessages(); file import.php in return $this->_getEntityAdapter()->getErrorMessages(); Now the error is visible. Fatal error: Uncaught exception 'Mage_Core_Exception' with message 'Entity is unknown' in /srv/www/vhosts/shop.proni.com/app/Mage.php:595 Stack trace: #0 /srv/www/vhosts/shop.proni.com/app/code/core/Mage/ImportExport/Model/Import.php(228): Mage::throwException('Entity is unkno...') #1 /srv/www/vhosts/shop.proni.com/app/code/core/Mage/ImportExport/Model/Import.php(93): Mage_ImportExport_Model_Import->getEntity() #2 /srv/www/vhosts/shop.proni.com/app/code/community/AvS/FastSimpleImport/Model/Import.php(498): Mage_ImportExport_Model_Import->_getEntityAdapter() #3 /srv/www/vhosts/shop.proni.com/sincro/importa-su-magento-customer.php(136): AvS_FastSimpleImport_Model_Import->getErrorMessages() #4 {main} thrown in /srv/www/vhosts/shop.proni.com/app/Mage.php on line 595