本文整理汇总了PHP中Mage_ImportExport_Model_Config类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_ImportExport_Model_Config类的具体用法?PHP Mage_ImportExport_Model_Config怎么用?PHP Mage_ImportExport_Model_Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_ImportExport_Model_Config类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getEntityAdapter
/**
* Create instance of entity adapter and return it
*
* @throws Mage_Core_Exception
* @return Mage_ImportExport_Model_Import_Entity_Abstract|Mage_ImportExport_Model_Import_EntityAbstract
*/
protected function _getEntityAdapter()
{
if (!$this->_entityAdapter) {
$entityTypes = Mage_ImportExport_Model_Config::getModels(self::CONFIG_KEY_ENTITIES);
if (isset($entityTypes[$this->getEntity()])) {
try {
$this->_entityAdapter = Mage::getModel($entityTypes[$this->getEntity()]['model']);
} catch (Exception $e) {
Mage::logException($e);
Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Invalid entity model'));
}
if (!$this->_entityAdapter instanceof Mage_ImportExport_Model_Import_Entity_Abstract && !$this->_entityAdapter instanceof Mage_ImportExport_Model_Import_EntityAbstract) {
Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Entity adapter object must be an instance of %s or %s', 'Mage_ImportExport_Model_Import_Entity_Abstract', 'Mage_ImportExport_Model_Import_EntityAbstract'));
}
// check for entity codes integrity
if ($this->getEntity() != $this->_entityAdapter->getEntityTypeCode()) {
Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Input entity code is not equal to entity adapter code'));
}
} else {
Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Invalid entity'));
}
$this->_entityAdapter->setParameters($this->getData());
}
return $this->_entityAdapter;
}
示例2: toOptionArray
/**
* Prepare and return array of import entities ids and their names
*
* @return array
*/
public function toOptionArray()
{
$options = array();
$entities = Mage_ImportExport_Model_Import::CONFIG_KEY_ENTITIES;
$comboOptions = Mage_ImportExport_Model_Config::getModelsComboOptions($entities);
foreach ($comboOptions as $option) {
$options[] = $option;
}
return $options;
}
示例3: getNewWriteInstance
public function getNewWriteInstance($destinationFile, $fileFormat)
{
$validWriters = Mage_ImportExport_Model_Config::getModels(self::CONFIG_KEY_FORMATS);
if (isset($validWriters[$fileFormat])) {
try {
if (file_exists($destinationFile)) {
unlink($destinationFile);
}
$writer = Mage::getModel($validWriters[$fileFormat]['model'], $destinationFile);
} catch (Exception $e) {
Mage::logException($e);
Mage::throwException(Mage::helper('importexport')->__('Invalid entity model'));
}
if (!$writer instanceof Mage_ImportExport_Model_Export_Adapter_Abstract) {
Mage::throwException(Mage::helper('importexport')->__('Adapter object must be an instance of %s', 'Mage_ImportExport_Model_Export_Adapter_Abstract'));
}
} else {
Mage::throwException(Mage::helper('importexport')->__('Invalid file format'));
}
return $writer;
}
示例4: toOptionArray
/**
* Prepare and return array of available export file formats.
*
* @return array
*/
public function toOptionArray()
{
$formats = Mage_ImportExport_Model_Export::CONFIG_KEY_FORMATS;
return Mage_ImportExport_Model_Config::getModelsComboOptions($formats);
}
示例5: _getWriter
/**
* Get writer object.
*
* @throws Mage_Core_Exception
* @return Mage_ImportExport_Model_Export_Adapter_Abstract
*/
protected function _getWriter()
{
if (!$this->_writer) {
$validWriters = Mage_ImportExport_Model_Config::getModels(self::CONFIG_KEY_FORMATS);
if (isset($validWriters[$this->getFileFormat()])) {
try {
$this->_writer = Mage::getModel($validWriters[$this->getFileFormat()]['model']);
} catch (Exception $e) {
Mage::logException($e);
Mage::throwException(Mage::helper('importexport')->__('Invalid entity model'));
}
if (!$this->_writer instanceof Mage_ImportExport_Model_Export_Adapter_Abstract) {
Mage::throwException(Mage::helper('importexport')->__('Adapter object must be an instance of %s', 'Mage_ImportExport_Model_Export_Adapter_Abstract'));
}
} else {
Mage::throwException(Mage::helper('importexport')->__('Invalid file format'));
}
}
return $this->_writer;
}
示例6: setEntityTypeCode
/**
* Valdiates and sets the entity type.
*
* @param string $entityTypeCode
* @return Danslo_ApiImport_Model_Resource_Import_Data
*/
public function setEntityTypeCode($entityTypeCode)
{
$allowedEntities = array_keys(Mage_ImportExport_Model_Config::getModels(Danslo_ApiImport_Model_Import::CONFIG_KEY_ENTITIES));
if (!in_array($entityTypeCode, $allowedEntities)) {
Mage::throwException('Specified entity type (%s) is not in allowed entity types: %s', $entityTypeCode, implode(', ', $allowedEntities));
}
$this->_entityTypeCode = $entityTypeCode;
return $this;
}
示例7: getEntitiesOptionArray
/**
* Get entities option array
*
* @param string $type
* @return array
*/
public function getEntitiesOptionArray($type = null)
{
$entitiesPath = Mage_ImportExport_Model_Import::CONFIG_KEY_ENTITIES;
$importEntities = Mage_ImportExport_Model_Config::getModelsArrayOptions($entitiesPath);
$entitiesPath = Mage_ImportExport_Model_Export::CONFIG_KEY_ENTITIES;
$entities = Mage_ImportExport_Model_Config::getModelsArrayOptions($entitiesPath);
switch ($type) {
case 'import':
return $importEntities;
case 'export':
return $entities;
default:
foreach ($importEntities as $key => &$entityName) {
$entities[$key] = $entityName;
}
return $entities;
}
}
示例8: toOptionArray
/**
* Prepare and return array of export entities ids and their names
*
* @return array
*/
public function toOptionArray()
{
return Mage_ImportExport_Model_Config::getModelsComboOptions(Mage_ImportExport_Model_Export::CONFIG_KEY_ENTITIES, true);
}
示例9: dryrunCategoryImport
/**
* Import products
*
* @param array $data
* @param string|null $behavior
*
* @return AvS_FastSimpleImport_Model_Import
*/
public function dryrunCategoryImport($data, $behavior = NULL)
{
$transport = new Varien_Object(array('import_data' => $data));
Mage::dispatchEvent('fastsimpleimport_dryrun_categories_before', array('import_data' => $transport));
$data = $transport->getImportData();
if (!is_null($behavior)) {
$this->setBehavior($behavior);
}
$this->setUseNestedArrays(false);
$this->setEntity(Mage_Catalog_Model_Category::ENTITY);
/** @var $entityAdapter AvS_FastSimpleImport_Model_Import_Entity_Category */
$validTypes = Mage_ImportExport_Model_Config::getModels(Mage_ImportExport_Model_Import::CONFIG_KEY_ENTITIES);
$entityAdapter = Mage::getModel($validTypes[$this->getEntity()]['model']);
$entityAdapter->setBehavior($this->getBehavior());
$entityAdapter->setErrorLimit($this->getErrorLimit());
$entityAdapter->setIgnoreDuplicates($this->getIgnoreDuplicates());
$entityAdapter->setUnsetEmptyFields($this->getUnsetEmptyFields());
$entityAdapter->setSymbolEmptyFields($this->getSymbolEmptyFields());
$entityAdapter->setSymbolIgnoreFields($this->getSymbolIgnoreFields());
$this->setEntityAdapter($entityAdapter);
$validationResult = $this->validateSource($data);
return $validationResult;
}