144 $aSearch = array(chr(13), chr(10),
'\'',
'"');
145 $aReplace = array(
' ',
' ',
''',
'"');
148 $sText = str_replace($aSearch, $aReplace, $sText);
150 $sText = str_replace($aReplace, $aSearch, $sText);
159 public function import()
175 if (!$this->_iRetryRows) {
177 foreach ($this->_aData as $key => $value) {
195 foreach ($aStatistics as $key => $value) {
196 if ($value[
'r'] ==
false) {
198 $this->_sReturn .=
"File[" . $this->_sPath .
"] - dataset number: $key - Error: " . $value[
'm'] .
" ---<br> " . PHP_EOL;
202 if ($iRetryRows != $this->_iRetryRows && $iRetryRows > 0) {
204 $this->_iRetryRows = $iRetryRows;
205 $this->_sReturn =
'';
235 'OXORDERID' =>
'OXORDERID',
236 'OXAMOUNT' =>
'OXAMOUNT',
237 'OXARTID' =>
'OXARTID',
238 'OXARTNUM' =>
'OXARTNUM',
239 'OXTITLE' =>
'OXTITLE',
240 'OXSELVARIANT' =>
'OXSELVARIANT',
241 'OXNETPRICE' =>
'OXNETPRICE',
242 'OXBRUTPRICE' =>
'OXBRUTPRICE',
244 'OXPERSPARAM' =>
'OXPERSPARAM',
245 'OXPRICE' =>
'OXPRICE',
246 'OXBPRICE' =>
'OXBPRICE',
247 'OXTPRICE' =>
'OXTPRICE',
248 'OXWRAPID' =>
'OXWRAPID',
249 'OXSTOCK' =>
'OXSTOCK',
250 'OXORDERSHOPID' =>
'OXORDERSHOPID',
251 'OXTOTALVAT' =>
'OXTOTALVAT'
267 'OXSHOPID' =>
'OXSHOPID',
268 'OXUSERID' =>
'OXUSERID',
269 'OXORDERDATE' =>
'OXORDERDATE',
270 'OXORDERNR' =>
'OXORDERNR',
271 'OXBILLCOMPANY' =>
'OXBILLCOMPANY',
272 'OXBILLEMAIL' =>
'OXBILLEMAIL',
273 'OXBILLFNAME' =>
'OXBILLFNAME',
274 'OXBILLLNAME' =>
'OXBILLLNAME',
275 'OXBILLSTREET' =>
'OXBILLSTREET',
276 'OXBILLSTREETNR' =>
'OXBILLSTREETNR',
277 'OXBILLADDINFO' =>
'OXBILLADDINFO',
278 'OXBILLUSTID' =>
'OXBILLUSTID',
279 'OXBILLCITY' =>
'OXBILLCITY',
280 'OXBILLCOUNTRY' =>
'OXBILLCOUNTRY',
281 'OXBILLZIP' =>
'OXBILLZIP',
282 'OXBILLFON' =>
'OXBILLFON',
283 'OXBILLFAX' =>
'OXBILLFAX',
284 'OXBILLSAL' =>
'OXBILLSAL',
285 'OXDELCOMPANY' =>
'OXDELCOMPANY',
286 'OXDELFNAME' =>
'OXDELFNAME',
287 'OXDELLNAME' =>
'OXDELLNAME',
288 'OXDELSTREET' =>
'OXDELSTREET',
289 'OXDELSTREETNR' =>
'OXDELSTREETNR',
290 'OXDELADDINFO' =>
'OXDELADDINFO',
291 'OXDELCITY' =>
'OXDELCITY',
292 'OXDELCOUNTRY' =>
'OXDELCOUNTRY',
293 'OXDELZIP' =>
'OXDELZIP',
294 'OXDELFON' =>
'OXDELFON',
295 'OXDELFAX' =>
'OXDELFAX',
296 'OXDELSAL' =>
'OXDELSAL',
297 'OXDELCOST' =>
'OXDELCOST',
298 'OXDELVAT' =>
'OXDELVAT',
299 'OXPAYCOST' =>
'OXPAYCOST',
300 'OXPAYVAT' =>
'OXPAYVAT',
301 'OXWRAPCOST' =>
'OXWRAPCOST',
302 'OXWRAPVAT' =>
'OXWRAPVAT',
303 'OXCARDID' =>
'OXCARDID',
304 'OXCARDTEXT' =>
'OXCARDTEXT',
305 'OXDISCOUNT' =>
'OXDISCOUNT',
306 'OXBILLNR' =>
'OXBILLNR',
307 'OXREMARK' =>
'OXREMARK',
308 'OXVOUCHERDISCOUNT' =>
'OXVOUCHERDISCOUNT',
309 'OXCURRENCY' =>
'OXCURRENCY',
310 'OXCURRATE' =>
'OXCURRATE',
311 'OXTRANSID' =>
'OXTRANSID',
312 'OXPAID' =>
'OXPAID',
314 'OXTRANSSTATUS' =>
'OXTRANSSTATUS',
315 'OXLANG' =>
'OXLANG',
316 'OXDELTYPE' =>
'OXDELTYPE'
329 if (!isset($sID) || !$sID) {
330 throw new Exception(
"ERROR: Articlenumber/ID missing!");
331 } elseif (strlen($sID) > 32) {
332 throw new Exception(
"ERROR: Articlenumber/ID longer then allowed (32 chars max.)!");
346 if ($sType ==
'oldOrder') {
349 $oType->setFunctionSuffix(
'OldOrder');
350 } elseif ($sType ==
'oldOrderArticle') {
353 $oType->setFunctionSuffix(
'OldOrderArticle');
354 } elseif ($sType ==
'article2vendor') {
356 $oType->setFieldList(array(
"OXID",
"OXVENDORID"));
357 } elseif ($sType ==
'mainarticle2categroy') {
359 $oType->setFieldList(array(
"OXOBJECTID",
"OXCATNID",
"OXTIME"));
360 $oType->setFunctionSuffix(
'mainarticle2category');
385 if ($this->_sCurrVersion ==
"0.1") {
388 $myConfig->setConfigParam(
'blMallCustomPrice',
false);
391 if (isset($aRow[
'OXID'])) {
400 $sResult = $this->
_save($oType, $aRow, $this->_sCurrVersion ==
"0.1");
415 if ($this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedAccessoire2Article[$aRow[
'OXARTICLENID']])) {
418 $oDb->execute(
"delete from oxaccessoire2article where oxarticlenid = " . $oDb->quote($aRow[
'OXARTICLENID']));
419 $this->_aImportedAccessoire2Article[$aRow[
'OXARTICLENID']] = 1;
422 $sResult = $this->
_save($oType, $aRow);
438 if ($this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedActions2Article[$aRow[
'OXARTID']])) {
442 $oDb->execute(
"delete from oxactions2article where oxartid = " . $oDb->quote($aRow[
'OXARTID']));
443 $this->_aImportedActions2Article[$aRow[
'OXARTID']] = 1;
446 $sResult = $this->
_save($oType, $aRow, $this->_sCurrVersion ==
"0.1");
462 if ($this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedObject2Category[$aRow[
'OXOBJECTID']])) {
465 $oDb->execute(
"delete from oxobject2category where oxobjectid = " . $oDb->quote($aRow[
'OXOBJECTID']));
466 $this->_aImportedObject2Category[$aRow[
'OXOBJECTID']] = 1;
469 $sResult = $this->
_save($oType, $aRow);
489 $sSql =
"select OXID from oxobject2category where oxobjectid = " . $oDb->quote($aRow[
'OXOBJECTID']) .
" and OXCATNID = " . $oDb->quote($aRow[
'OXCATNID']);
490 $aRow[
'OXID'] = $oDb->getOne($sSql,
false,
false);
492 $sResult = $this->
_save($oType, $aRow);
493 if ((
boolean) $sResult) {
494 $sSql =
"Update oxobject2category set oxtime = oxtime+10 where oxobjectid = " . $oDb->quote($aRow[
'OXOBJECTID']) .
" and oxcatnid != " . $oDb->quote($aRow[
'OXCATNID']) .
" and oxshopid = '" .
$myConfig->getShopId() .
"'";
495 $oDb->Execute($sSql);
511 $sResult = $this->
_save($oType, $aRow, $this->_sCurrVersion ==
"0.1");
527 if ($this->_sCurrVersion ==
"0.1" && !isset($this->_aImportedObject2Article[$aRow[
'OXARTICLENID']])) {
530 $oDb->Execute(
"delete from oxobject2article where oxarticlenid = " . $oDb->quote($aRow[
'OXARTICLENID']));
531 $this->aImportedObject2Article[$aRow[
'OXARTICLENID']] = 1;
534 $sResult = $this->
_save($oType, $aRow);
549 $sResult = $this->
_save($oType, $aRow, $this->_sCurrVersion ==
"0.1");
564 $sResult = $this->
_save($oType, $aRow);
581 $sResult = $this->
_save($oType, $aRow);
596 $oOrderArt =
oxNew(
"oxorderarticle",
"core");
597 $oOrderArt->load($aRow[
'OXID']);
599 if ($oOrderArt->getId()) {
602 if ($this->_sCurrVersion !=
"0.1") {
607 $aStatuses = unserialize($oOrderArt->oxorderarticles__oxerpstatus->value);
609 $oStatus =
new stdClass();
610 $oStatus->STATUS = $aRow[
'OXERPSTATUS_STATUS'];
611 $oStatus->date = $aRow[
'OXERPSTATUS_TIME'];
612 $oStatus->trackingid = $aRow[
'OXERPSTATUS_TRACKID'];
614 $aStatuses[$aRow[
'OXERPSTATUS_TIME']] = $oStatus;
638 if (isset($aRow[
'OXUSERNAME'])) {
639 $sID = $aRow[
'OXID'];
640 $sUserName = $aRow[
'OXUSERNAME'];
642 $oUser =
oxNew(
"oxuser",
"core");
647 if ($oUser->exists($sID) && $sID != $oUser->getId()) {
648 throw new Exception(
"USER $sUserName already exists!");
653 $sResult = $this->
_save($oType, $aRow);
668 $sResult = $this->
_save($oType, $aRow, $this->_sCurrVersion ==
"0.1");
686 $sResult = $this->
_save($oType, $aRow);
701 $sResult = $this->
_save($oType, $aRow);
716 $sResult = $this->
_save($oType, $aRow);
727 return count($this->_aImportedIds);
736 if (!array_key_exists($key, $this->_aImportedIds)) {
737 $this->_aImportedIds[$key] =
true;