145 $aSearch = array( chr(13), chr(10),
'\'',
'"' );
146 $aReplace = array(
' ',
' ',
''',
'"' );
149 $sText = str_replace( $aSearch, $aReplace, $sText );
151 $sText = str_replace( $aReplace, $aSearch, $sText );
162 public function import()
178 if ( !$this->_iRetryRows ) {
180 foreach ($this->_aData as $key => $value) {
198 foreach ( $aStatistics as $key => $value) {
199 if ( $value[
'r'] ==
false ) {
201 $this->_sReturn .=
"File[".$this->_sPath.
"] - dataset number: $key - Error: ".$value[
'm'].
" ---<br> ".PHP_EOL;
205 if ( $iRetryRows != $this->_iRetryRows && $iRetryRows>0 ) {
207 $this->_iRetryRows = $iRetryRows;
208 $this->_sReturn =
'';
238 'OXORDERID' =>
'OXORDERID',
239 'OXAMOUNT' =>
'OXAMOUNT',
240 'OXARTID' =>
'OXARTID',
241 'OXARTNUM' =>
'OXARTNUM',
242 'OXTITLE' =>
'OXTITLE',
243 'OXSELVARIANT' =>
'OXSELVARIANT',
244 'OXNETPRICE' =>
'OXNETPRICE',
245 'OXBRUTPRICE' =>
'OXBRUTPRICE',
247 'OXPERSPARAM' =>
'OXPERSPARAM',
248 'OXPRICE' =>
'OXPRICE',
249 'OXBPRICE' =>
'OXBPRICE',
250 'OXTPRICE' =>
'OXTPRICE',
251 'OXWRAPID' =>
'OXWRAPID',
252 'OXSTOCK' =>
'OXSTOCK',
253 'OXORDERSHOPID' =>
'OXORDERSHOPID',
254 'OXTOTALVAT' =>
'OXTOTALVAT'
270 'OXSHOPID' =>
'OXSHOPID',
271 'OXUSERID' =>
'OXUSERID',
272 'OXORDERDATE' =>
'OXORDERDATE',
273 'OXORDERNR' =>
'OXORDERNR',
274 'OXBILLCOMPANY' =>
'OXBILLCOMPANY',
275 'OXBILLEMAIL' =>
'OXBILLEMAIL',
276 'OXBILLFNAME' =>
'OXBILLFNAME',
277 'OXBILLLNAME' =>
'OXBILLLNAME',
278 'OXBILLSTREET' =>
'OXBILLSTREET',
279 'OXBILLSTREETNR' =>
'OXBILLSTREETNR',
280 'OXBILLADDINFO' =>
'OXBILLADDINFO',
281 'OXBILLUSTID' =>
'OXBILLUSTID',
282 'OXBILLCITY' =>
'OXBILLCITY',
283 'OXBILLCOUNTRY' =>
'OXBILLCOUNTRY',
284 'OXBILLZIP' =>
'OXBILLZIP',
285 'OXBILLFON' =>
'OXBILLFON',
286 'OXBILLFAX' =>
'OXBILLFAX',
287 'OXBILLSAL' =>
'OXBILLSAL',
288 'OXDELCOMPANY' =>
'OXDELCOMPANY',
289 'OXDELFNAME' =>
'OXDELFNAME',
290 'OXDELLNAME' =>
'OXDELLNAME',
291 'OXDELSTREET' =>
'OXDELSTREET',
292 'OXDELSTREETNR' =>
'OXDELSTREETNR',
293 'OXDELADDINFO' =>
'OXDELADDINFO',
294 'OXDELCITY' =>
'OXDELCITY',
295 'OXDELCOUNTRY' =>
'OXDELCOUNTRY',
296 'OXDELZIP' =>
'OXDELZIP',
297 'OXDELFON' =>
'OXDELFON',
298 'OXDELFAX' =>
'OXDELFAX',
299 'OXDELSAL' =>
'OXDELSAL',
300 'OXDELCOST' =>
'OXDELCOST',
301 'OXDELVAT' =>
'OXDELVAT',
302 'OXPAYCOST' =>
'OXPAYCOST',
303 'OXPAYVAT' =>
'OXPAYVAT',
304 'OXWRAPCOST' =>
'OXWRAPCOST',
305 'OXWRAPVAT' =>
'OXWRAPVAT',
306 'OXCARDID' =>
'OXCARDID',
307 'OXCARDTEXT' =>
'OXCARDTEXT',
308 'OXDISCOUNT' =>
'OXDISCOUNT',
309 'OXBILLNR' =>
'OXBILLNR',
310 'OXREMARK' =>
'OXREMARK',
311 'OXVOUCHERDISCOUNT' =>
'OXVOUCHERDISCOUNT',
312 'OXCURRENCY' =>
'OXCURRENCY',
313 'OXCURRATE' =>
'OXCURRATE',
314 'OXTRANSID' =>
'OXTRANSID',
315 'OXPAID' =>
'OXPAID',
317 'OXTRANSSTATUS' =>
'OXTRANSSTATUS',
318 'OXLANG' =>
'OXLANG',
319 'OXDELTYPE' =>
'OXDELTYPE'
334 if ( !isset( $sID ) || !$sID ) {
335 throw new Exception(
"ERROR: Articlenumber/ID missing!");
336 } elseif ( strlen( $sID) > 32 ) {
337 throw new Exception(
"ERROR: Articlenumber/ID longer then allowed (32 chars max.)!");
351 if ( $sType ==
'oldOrder' ) {
354 $oType->setFunctionSuffix(
'OldOrder');
355 } elseif ( $sType ==
'oldOrderArticle' ) {
358 $oType->setFunctionSuffix(
'OldOrderArticle');
359 } elseif ( $sType ==
'article2vendor' ) {
361 $oType->setFieldList(array(
"OXID",
"OXVENDORID"));
362 } elseif ( $sType ==
'mainarticle2categroy') {
364 $oType->setFieldList(array(
"OXOBJECTID",
"OXCATNID",
"OXTIME"));
365 $oType->setFunctionSuffix(
'mainarticle2category');
390 if ( $this->_sCurrVersion ==
"0.1" ) {
393 $myConfig->setConfigParam(
'blMallCustomPrice',
false);
396 if ( isset($aRow[
'OXID'] ) ) {
405 $sResult = $this->
_save( $oType, $aRow, $this->_sCurrVersion ==
"0.1");
420 if ( $this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedAccessoire2Article[$aRow[
'OXARTICLENID']] ) ) {
423 $oDb->execute(
"delete from oxaccessoire2article where oxarticlenid = ".$oDb->quote( $aRow[
'OXARTICLENID'] ) );
424 $this->_aImportedAccessoire2Article[$aRow[
'OXARTICLENID']] = 1;
427 $sResult = $this->
_save( $oType, $aRow);
442 if ( $this->_sCurrVersion ==
"0.1" && !isset( $this->_aImportedActions2Article[$aRow[
'OXARTID']] ) ) {
446 $oDb->execute(
"delete from oxactions2article where oxartid = ".$oDb->quote( $aRow[
'OXARTID'] ) );
447 $this->_aImportedActions2Article[$aRow[
'OXARTID']] = 1;
450 $sResult = $this->
_save( $oType, $aRow, $this->_sCurrVersion ==
"0.1");
465 if ( $this->_sCurrVersion ==
"0.1" && !isset( $this->_aImportedObject2Category[$aRow[
'OXOBJECTID']] ) ) {
468 $oDb->execute(
"delete from oxobject2category where oxobjectid = ".$oDb->quote( $aRow[
'OXOBJECTID'] ) );
469 $this->_aImportedObject2Category[$aRow[
'OXOBJECTID']] = 1;
472 $sResult = $this->
_save( $oType, $aRow);
491 $sSql =
"select OXID from oxobject2category where oxobjectid = ".$oDb->quote( $aRow[
'OXOBJECTID'] ).
" and OXCATNID = ".$oDb->quote( $aRow[
'OXCATNID'] );
492 $aRow[
'OXID'] = $oDb->getOne( $sSql,
false,
false );
494 $sResult = $this->
_save( $oType, $aRow);
495 if ((
boolean) $sResult) {
496 $sSql =
"Update oxobject2category set oxtime = oxtime+10 where oxobjectid = ".$oDb->quote( $aRow[
'OXOBJECTID'] ) .
" and oxcatnid != ".$oDb->quote( $aRow[
'OXCATNID'] ) .
" and oxshopid = '".
$myConfig->getShopId().
"'";
497 $oDb->Execute($sSql);
513 $sResult = $this->
_save( $oType, $aRow, $this->_sCurrVersion ==
"0.1");
528 if ( $this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedObject2Article[$aRow[
'OXARTICLENID']] ) ) {
531 $oDb->Execute(
"delete from oxobject2article where oxarticlenid = ".$oDb->quote( $aRow[
'OXARTICLENID'] ) );
532 $this->aImportedObject2Article[$aRow[
'OXARTICLENID']] = 1;
535 $sResult = $this->
_save( $oType, $aRow);
549 $sResult = $this->
_save( $oType, $aRow, $this->_sCurrVersion ==
"0.1");
563 $sResult = $this->
_save( $oType, $aRow);
579 $sResult = $this->
_save( $oType, $aRow);
593 $oOrderArt =
oxNew(
"oxorderarticle",
"core");
594 $oOrderArt->load( $aRow[
'OXID']);
596 if ( $oOrderArt->getId()) {
599 if ( $this->_sCurrVersion !=
"0.1") {
604 $aStatuses = unserialize( $oOrderArt->oxorderarticles__oxerpstatus->value );
606 $oStatus =
new stdClass();
607 $oStatus->STATUS = $aRow[
'OXERPSTATUS_STATUS'];
608 $oStatus->date = $aRow[
'OXERPSTATUS_TIME'];
609 $oStatus->trackingid = $aRow[
'OXERPSTATUS_TRACKID'];
611 $aStatuses[$aRow[
'OXERPSTATUS_TIME']] = $oStatus;
634 if ( isset($aRow[
'OXUSERNAME'] ) ) {
635 $sID = $aRow[
'OXID'];
636 $sUserName = $aRow[
'OXUSERNAME'];
638 $oUser =
oxNew(
"oxuser",
"core");
643 if ( $oUser->exists( $sID) && $sID != $oUser->getId() ) {
644 throw new Exception(
"USER $sUserName already exists!");
649 $sResult = $this->
_save( $oType, $aRow);
663 $sResult = $this->
_save( $oType, $aRow, $this->_sCurrVersion ==
"0.1");
680 $sResult = $this->
_save( $oType, $aRow);
694 $sResult = $this->
_save( $oType, $aRow);
708 $sResult = $this->
_save( $oType, $aRow);
718 return count ( $this->_aImportedIds );
729 if ( !array_key_exists( $key, $this->_aImportedIds ) )
730 $this->_aImportedIds[$key] =
true;