Skip to content

Commit

Permalink
This commit refs #61420: Fixed Delimiter for 3rd Parties
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdkdkussin committed Jan 10, 2024
1 parent a6cd685 commit 25f379f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
10 changes: 7 additions & 3 deletions modules/wmdk/wmdkffexportqueue/Traits/ExportTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ trait ExportTrait
'success' => TRUE,

'channel' => NULL,
'selected' => 0,
'products' => 0,
'skipped' => 0,

Expand Down Expand Up @@ -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) {
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,14 @@ private function _convertValue($sKey, $sValue)

private function _convertToCData($sValue)
{
return "<![CDATA[" . $sValue . "]]>";
return array(
'_cdata' => $sValue,
);
}

private function _revertFromCData($sValue)
{
return str_replace(array(
'<![CDATA[',
']]>',
), array(
'',
'',
), $sValue);
return (is_array($sValue) && isset($sValue['_cdata'])) ? $sValue['_cdata'] : $sValue;
}

// TODO: Remove FIX #61380
Expand Down Expand Up @@ -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]);
}
}
}
Expand Down
13 changes: 12 additions & 1 deletion modules/wmdk/wmdkffexportqueue/views/wmdkffexport_doofinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion modules/wmdk/wmdkffexportqueue/views/wmdkffexport_sooqr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 25f379f

Please sign in to comment.