146 $aSearch = array(chr(13), chr(10),
'\'',
'"');
147 $aReplace = array(
' ',
' ',
''',
'"');
150 $sText = str_replace($aSearch, $aReplace, $sText);
152 $sText = str_replace($aReplace, $aSearch, $sText);
161 public function import()
177 if (!$this->_iRetryRows) {
179 foreach ($this->_aData as $key => $value) {
197 foreach ($aStatistics as $key => $value) {
198 if ($value[
'r'] ==
false) {
200 $this->_sReturn .=
"File[" . $this->_sPath .
"] - dataset number: $key - Error: " . $value[
'm'] .
" ---<br> " . PHP_EOL;
204 if ($iRetryRows != $this->_iRetryRows && $iRetryRows > 0) {
206 $this->_iRetryRows = $iRetryRows;
207 $this->_sReturn =
'';
237 'OXORDERID' =>
'OXORDERID',
238 'OXAMOUNT' =>
'OXAMOUNT',
239 'OXARTID' =>
'OXARTID',
240 'OXARTNUM' =>
'OXARTNUM',
241 'OXTITLE' =>
'OXTITLE',
242 'OXSELVARIANT' =>
'OXSELVARIANT',
243 'OXNETPRICE' =>
'OXNETPRICE',
244 'OXBRUTPRICE' =>
'OXBRUTPRICE',
246 'OXPERSPARAM' =>
'OXPERSPARAM',
247 'OXPRICE' =>
'OXPRICE',
248 'OXBPRICE' =>
'OXBPRICE',
249 'OXTPRICE' =>
'OXTPRICE',
250 'OXWRAPID' =>
'OXWRAPID',
251 'OXSTOCK' =>
'OXSTOCK',
252 'OXORDERSHOPID' =>
'OXORDERSHOPID',
253 'OXTOTALVAT' =>
'OXTOTALVAT'
269 'OXSHOPID' =>
'OXSHOPID',
270 'OXUSERID' =>
'OXUSERID',
271 'OXORDERDATE' =>
'OXORDERDATE',
272 'OXORDERNR' =>
'OXORDERNR',
273 'OXBILLCOMPANY' =>
'OXBILLCOMPANY',
274 'OXBILLEMAIL' =>
'OXBILLEMAIL',
275 'OXBILLFNAME' =>
'OXBILLFNAME',
276 'OXBILLLNAME' =>
'OXBILLLNAME',
277 'OXBILLSTREET' =>
'OXBILLSTREET',
278 'OXBILLSTREETNR' =>
'OXBILLSTREETNR',
279 'OXBILLADDINFO' =>
'OXBILLADDINFO',
280 'OXBILLUSTID' =>
'OXBILLUSTID',
281 'OXBILLCITY' =>
'OXBILLCITY',
282 'OXBILLCOUNTRY' =>
'OXBILLCOUNTRY',
283 'OXBILLZIP' =>
'OXBILLZIP',
284 'OXBILLFON' =>
'OXBILLFON',
285 'OXBILLFAX' =>
'OXBILLFAX',
286 'OXBILLSAL' =>
'OXBILLSAL',
287 'OXDELCOMPANY' =>
'OXDELCOMPANY',
288 'OXDELFNAME' =>
'OXDELFNAME',
289 'OXDELLNAME' =>
'OXDELLNAME',
290 'OXDELSTREET' =>
'OXDELSTREET',
291 'OXDELSTREETNR' =>
'OXDELSTREETNR',
292 'OXDELADDINFO' =>
'OXDELADDINFO',
293 'OXDELCITY' =>
'OXDELCITY',
294 'OXDELCOUNTRY' =>
'OXDELCOUNTRY',
295 'OXDELZIP' =>
'OXDELZIP',
296 'OXDELFON' =>
'OXDELFON',
297 'OXDELFAX' =>
'OXDELFAX',
298 'OXDELSAL' =>
'OXDELSAL',
299 'OXDELCOST' =>
'OXDELCOST',
300 'OXDELVAT' =>
'OXDELVAT',
301 'OXPAYCOST' =>
'OXPAYCOST',
302 'OXPAYVAT' =>
'OXPAYVAT',
303 'OXWRAPCOST' =>
'OXWRAPCOST',
304 'OXWRAPVAT' =>
'OXWRAPVAT',
305 'OXCARDID' =>
'OXCARDID',
306 'OXCARDTEXT' =>
'OXCARDTEXT',
307 'OXDISCOUNT' =>
'OXDISCOUNT',
308 'OXBILLNR' =>
'OXBILLNR',
309 'OXREMARK' =>
'OXREMARK',
310 'OXVOUCHERDISCOUNT' =>
'OXVOUCHERDISCOUNT',
311 'OXCURRENCY' =>
'OXCURRENCY',
312 'OXCURRATE' =>
'OXCURRATE',
313 'OXTRANSID' =>
'OXTRANSID',
314 'OXPAID' =>
'OXPAID',
316 'OXTRANSSTATUS' =>
'OXTRANSSTATUS',
317 'OXLANG' =>
'OXLANG',
318 'OXDELTYPE' =>
'OXDELTYPE'
331 if (!isset($sID) || !$sID) {
332 throw new Exception(
"ERROR: Articlenumber/ID missing!");
333 } elseif (strlen($sID) > 32) {
334 throw new Exception(
"ERROR: Articlenumber/ID longer then allowed (32 chars max.)!");
348 if ($sType ==
'oldOrder') {
351 $oType->setFunctionSuffix(
'OldOrder');
352 } elseif ($sType ==
'oldOrderArticle') {
355 $oType->setFunctionSuffix(
'OldOrderArticle');
356 } elseif ($sType ==
'article2vendor') {
358 $oType->setFieldList(array(
"OXID",
"OXVENDORID"));
359 } elseif ($sType ==
'mainarticle2categroy') {
361 $oType->setFieldList(array(
"OXOBJECTID",
"OXCATNID",
"OXTIME"));
362 $oType->setFunctionSuffix(
'mainarticle2category');
387 if ($this->_sCurrVersion ==
"0.1") {
390 $myConfig->setConfigParam(
'blMallCustomPrice',
false);
393 if (isset($aRow[
'OXID'])) {
402 $sResult = $this->
_save($oType, $aRow, $this->_sCurrVersion ==
"0.1");
417 if ($this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedAccessoire2Article[$aRow[
'OXARTICLENID']])) {
420 $oDb->execute(
"delete from oxaccessoire2article where oxarticlenid = " . $oDb->quote($aRow[
'OXARTICLENID']));
421 $this->_aImportedAccessoire2Article[$aRow[
'OXARTICLENID']] = 1;
424 $sResult = $this->
_save($oType, $aRow);
440 if ($this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedActions2Article[$aRow[
'OXARTID']])) {
444 $oDb->execute(
"delete from oxactions2article where oxartid = " . $oDb->quote($aRow[
'OXARTID']));
445 $this->_aImportedActions2Article[$aRow[
'OXARTID']] = 1;
448 $sResult = $this->
_save($oType, $aRow, $this->_sCurrVersion ==
"0.1");
464 if ($this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedObject2Category[$aRow[
'OXOBJECTID']])) {
467 $oDb->execute(
"delete from oxobject2category where oxobjectid = " . $oDb->quote($aRow[
'OXOBJECTID']));
468 $this->_aImportedObject2Category[$aRow[
'OXOBJECTID']] = 1;
471 $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");
529 if ($this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedObject2Article[$aRow[
'OXARTICLENID']])) {
532 $oDb->Execute(
"delete from oxobject2article where oxarticlenid = " . $oDb->quote($aRow[
'OXARTICLENID']));
533 $this->aImportedObject2Article[$aRow[
'OXARTICLENID']] = 1;
536 $sResult = $this->
_save($oType, $aRow);
551 $sResult = $this->
_save($oType, $aRow, $this->_sCurrVersion ==
"0.1");
566 $sResult = $this->
_save($oType, $aRow);
583 $sResult = $this->
_save($oType, $aRow);
598 $oOrderArt =
oxNew(
"oxorderarticle",
"core");
599 $oOrderArt->load($aRow[
'OXID']);
601 if ($oOrderArt->getId()) {
604 if ($this->_sCurrVersion !=
"0.1") {
609 $aStatuses = unserialize($oOrderArt->oxorderarticles__oxerpstatus->value);
611 $oStatus =
new stdClass();
612 $oStatus->STATUS = $aRow[
'OXERPSTATUS_STATUS'];
613 $oStatus->date = $aRow[
'OXERPSTATUS_TIME'];
614 $oStatus->trackingid = $aRow[
'OXERPSTATUS_TRACKID'];
616 $aStatuses[$aRow[
'OXERPSTATUS_TIME']] = $oStatus;
640 if (isset($aRow[
'OXUSERNAME'])) {
641 $sID = $aRow[
'OXID'];
642 $sUserName = $aRow[
'OXUSERNAME'];
644 $oUser =
oxNew(
"oxuser",
"core");
649 if ($oUser->exists($sID) && $sID != $oUser->getId()) {
650 throw new Exception(
"USER $sUserName already exists!");
655 $sResult = $this->
_save($oType, $aRow);
670 $sResult = $this->
_save($oType, $aRow, $this->_sCurrVersion ==
"0.1");
688 $sResult = $this->
_save($oType, $aRow);
703 $sResult = $this->
_save($oType, $aRow);
718 $sResult = $this->
_save($oType, $aRow);
729 return count($this->_aImportedIds);
738 if (!array_key_exists($key, $this->_aImportedIds)) {
739 $this->_aImportedIds[$key] =
true;