From 25f379ff59e112be210e65b40c13845cebd6e695 Mon Sep 17 00:00:00 2001 From: Daniel Kussin Date: Wed, 10 Jan 2024 10:52:43 +0100 Subject: [PATCH] This commit refs #61420: Fixed Delimiter for 3rd Parties --- .../wmdk/wmdkffexportqueue/Traits/ExportTrait.php | 10 +++++++--- .../Traits/ThirdPartyConverterTrait.php | 14 +++++--------- .../views/wmdkffexport_doofinder.php | 13 ++++++++++++- .../views/wmdkffexport_export.php | 1 + .../wmdkffexportqueue/views/wmdkffexport_sooqr.php | 3 ++- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/modules/wmdk/wmdkffexportqueue/Traits/ExportTrait.php b/modules/wmdk/wmdkffexportqueue/Traits/ExportTrait.php index 34ce251..2051edb 100644 --- a/modules/wmdk/wmdkffexportqueue/Traits/ExportTrait.php +++ b/modules/wmdk/wmdkffexportqueue/Traits/ExportTrait.php @@ -26,6 +26,7 @@ trait ExportTrait 'success' => TRUE, 'channel' => NULL, + 'selected' => 0, 'products' => 0, 'skipped' => 0, @@ -54,7 +55,7 @@ public function render() { return $this->_sTemplate; } - private function _getCSVDataRow($aFields) { + private function _getCSVDataRow($aFields, $sDelimiter = self::EXPORT_DELIMITER) { $aTmpCsvData = array(); foreach ($aFields as $iKey => $sValue) { @@ -75,7 +76,7 @@ private function _getCSVDataRow($aFields) { $aTmpCsvData[] = self::EXPORT_ADDITIONAL_ESCAPING . $this->_excapeString( $sExportData ) . self::EXPORT_ADDITIONAL_ESCAPING; } - return implode(self::EXPORT_DELIMITER, $aTmpCsvData); + return implode($sDelimiter, $aTmpCsvData); } private function _loadData() { @@ -112,6 +113,9 @@ private function _loadData() { if ($oResult != FALSE && $oResult->count() > 0) { + // LOG + $this->_aResponse['selected'] = $oResult->count(); + // ADD CSV Header array_shift($this->_aExportFields); $this->_aCsvData[] = $this->_getCSVDataRow($this->_aExportFields); @@ -123,7 +127,7 @@ private function _loadData() { $sOxid = array_shift($aData); // CLEAN DATA - $sCSVDataRow = $this->_getCSVDataRow($aData); + $sCSVDataRow = $this->_getCSVDataRow($aData, self::TMP_EXPORT_DELIMITER); if (!$this->_bSkipCSVDataRow) { $sCsvData = $sCSVDataRow; diff --git a/modules/wmdk/wmdkffexportqueue/Traits/ThirdPartyConverterTrait.php b/modules/wmdk/wmdkffexportqueue/Traits/ThirdPartyConverterTrait.php index 2298744..94bd223 100644 --- a/modules/wmdk/wmdkffexportqueue/Traits/ThirdPartyConverterTrait.php +++ b/modules/wmdk/wmdkffexportqueue/Traits/ThirdPartyConverterTrait.php @@ -77,18 +77,14 @@ private function _convertValue($sKey, $sValue) private function _convertToCData($sValue) { - return ""; + return array( + '_cdata' => $sValue, + ); } private function _revertFromCData($sValue) { - return str_replace(array( - '', - ), array( - '', - '', - ), $sValue); + return (is_array($sValue) && isset($sValue['_cdata'])) ? $sValue['_cdata'] : $sValue; } // TODO: Remove FIX #61380 @@ -171,7 +167,7 @@ private function _addAttributesAsNodes($aProductData) ), $aData[0]); // ADD ADDITIONAL NODE - $aProductData[$sNodeName] = $this->_fixCDataWrapper($aData[1]); + $aProductData[$sNodeName] = $this->_convertToCData($aData[1]); } } } diff --git a/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_doofinder.php b/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_doofinder.php index b2a1928..d30c550 100644 --- a/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_doofinder.php +++ b/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_doofinder.php @@ -17,6 +17,7 @@ class wmdkffexport_doofinder extends oxubase const EXPORT_ADDITIONAL_ESCAPING = ''; const EXPORT_DELIMITER = ','; + const TMP_EXPORT_DELIMITER = '#%#%#'; const EXPORT_CATEGORY_DELIMITER = '|'; private $_aExportData = NULL; @@ -77,10 +78,20 @@ protected function _getData() { continue; } - $aValues = explode(self::EXPORT_DELIMITER, $sRow); + $aValues = explode(self::TMP_EXPORT_DELIMITER, $sRow); if (count($aKeys) == count($aValues)) { $aData[] = $this->_convertData(array_combine($aKeys, $aValues)); + } else { + // ERROR + var_dump(array( + 'delimiter' => self::EXPORT_DELIMITER, + 'tmp_delimiter' => self::TMP_EXPORT_DELIMITER, + 'row' => $sRow, + 'keys' => $aKeys, + 'values' => $aValues, + )); + die(); } } diff --git a/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_export.php b/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_export.php index 6224b3e..2be4560 100644 --- a/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_export.php +++ b/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_export.php @@ -14,6 +14,7 @@ class wmdkffexport_export extends oxubase const EXPORT_ADDITIONAL_ESCAPING = '"'; const EXPORT_DELIMITER = '|'; + const TMP_EXPORT_DELIMITER = '#%#%#'; const EXPORT_CATEGORY_DELIMITER = '|'; private $_sTemplate = 'wmdkffexport_export.tpl'; diff --git a/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_sooqr.php b/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_sooqr.php index 3ce15ab..c09fe0d 100644 --- a/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_sooqr.php +++ b/modules/wmdk/wmdkffexportqueue/views/wmdkffexport_sooqr.php @@ -17,6 +17,7 @@ class wmdkffexport_sooqr extends oxubase const EXPORT_ADDITIONAL_ESCAPING = ''; const EXPORT_DELIMITER = '|'; + const TMP_EXPORT_DELIMITER = '#%#%#'; const EXPORT_CATEGORY_DELIMITER = '###'; private $_aExportData = NULL; @@ -74,7 +75,7 @@ protected function _getData() { continue; } - $aValues = explode(self::EXPORT_DELIMITER, $sRow); + $aValues = explode(self::TMP_EXPORT_DELIMITER, $sRow); if (count($aKeys) == count($aValues)) { $aData[] = $this->_convertData(array_combine($aKeys, $aValues));