127 lignes
3.6 KiB
PHP

<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* https://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development <support@shopmodule.com>
* @link https://www.oxidmodule.com
*/
namespace D3\Importer\Application\Controller\Admin\Articleimport;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
use Exception;
use D3\Importer\Application\Controller\Admin\Base;
use D3\Importer\Application\Models\Constants;
use D3\Importer\Application\Models\ImportConfig;
use OxidEsales\Eshop\Core\Request;
/**
* Importer attribute manager.
*
* @package admin
*/
class Attribute extends Base
{
/**
* Current class default template name.
*
* @var string
*/
protected $_sThisTemplate = '@' . Constants::OXID_MODULE_ID . '/admin/d3_importer_attrib';
protected $currentProfileName = 'd3_importer_attrib';
/**
* Executes parent method parent::render(), creates oxlist object,
* passes its data to Smarty engine and retutns name of template
* file "d3_importer_category.tpl".
*
* @return string
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws StandardException
*/
public function render()
{
$sReturn = parent::render();
$this->readCurrentCSVLine();
$this->addTplParam(
'attributeOldValues',
is_string($this->getD3ImporterConfiguration()->getImportProfile('d3_importer_attrib')['IMPORTCOLUM'] ?? [])
);
return $sReturn;
}
/**
*
* @throws Exception
* @throws d3_cfg_mod_exception
* @throws DatabaseConnectionException
*/
public function saveImportProfile(array $aXMLParams = [])
{
$request = oxNew(Request::class);
$aXMLParams = $request->getRequestParameter("xmlval");
if ($request->getRequestParameter("deleteOldSettings") == 'delete') {
unset($aXMLParams['IMPORTCOLUM']);
}
if (is_array($aXMLParams['IMPORTCOLUM'])) {
foreach ($aXMLParams['IMPORTCOLUM'] as $sIndex => $aImportColum) {
if ($this->isArrayEmpty($aImportColum)) {
unset($aXMLParams['IMPORTCOLUM'][$sIndex]);
}
}
}
parent::saveImportProfile($aXMLParams);
}
/**
* @param $mValue
*
* @return bool
*/
protected function isArrayEmpty($mValue)
{
$Result = true;
if (is_array($mValue) && count($mValue) > 0) {
foreach ($mValue as $Value) {
$Result = $Result && $this->isArrayEmpty($Value);
}
} else {
$Result = $mValue == '';//don't use empty()
}
return $Result;
}
/**
* @return array
*/
protected function getFormularElements(ImportConfig $oImportConfig)
{
// TODO: Implement _getFormularElements() method.
return [];
}
}