Exemple #1
0
 /**
  * Fires off the import process through the import model.
  *
  * @param array $entities
  * @param string $entityType
  * @param string $behavior
  * @return array
  */
 public function importEntities($entities, $entityType = null, $behavior = null)
 {
     $this->_setEntityTypeCode($entityType ? $entityType : Mage_Catalog_Model_Product::ENTITY);
     $this->_setBehavior($behavior ? $behavior : Mage_ImportExport_Model_Import::BEHAVIOR_REPLACE);
     $this->_api->getDataSourceModel()->setEntities($entities);
     try {
         $result = $this->_api->importSource();
     } catch (Mage_Core_Exception $e) {
         $this->_fault('import_failed', $e->getMessage());
     }
     return array($result);
 }
Exemple #2
0
 /**
  * Fires off the import process through the import model.
  *
  * @param array $entities
  * @param string $entityType
  * @param string $behavior
  * @return array
  */
 public function importEntities($entities, $entityType = null, $behavior = null)
 {
     $this->_setEntityTypeCode($entityType ? $entityType : Mage_Catalog_Model_Product::ENTITY);
     $this->_setBehavior($behavior ? $behavior : Mage_ImportExport_Model_Import::BEHAVIOR_REPLACE);
     $this->_api->getDataSourceModel()->setEntities($entities);
     try {
         $result = $this->_api->importSource();
         $errorsCount = $this->_api->getErrorsCount();
         if ($errorsCount > 0) {
             Mage::throwException("There were {$errorsCount} errors during the import process." . "Please be aware that valid entities were still imported.");
         }
     } catch (Mage_Core_Exception $e) {
         $this->_fault('import_failed', $e->getMessage());
     }
     return array($result);
 }