Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * Validate data rows and save bunches to DB
  *
  * @return Mage_ImportExport_Model_Import_Entity_Product
  */
 protected function _saveValidatedBunches()
 {
     $source = $this->_getSource();
     $source->rewind();
     while ($source->valid()) {
         if ($this->_errorsCount >= $this->_errorsLimit) {
             // errors limit check
             return $this;
         }
         $rowData = $source->current();
         $this->validateRow($rowData, $source->key());
         $source->next();
     }
     $this->getOptionEntity()->validateAmbiguousData();
     return parent::_saveValidatedBunches();
 }
Exemple #3
0
 /**
  * Set valid attribute set and product type to rows with all scopes
  * to ensure that existing products doesn't changed.
  *
  * @param array $rowData
  * @return array
  */
 protected function _prepareRowForDb(array $rowData)
 {
     $rowData = parent::_prepareRowForDb($rowData);
     static $lastSku = null;
     if (Mage_ImportExport_Model_Import::BEHAVIOR_DELETE == $this->getBehavior()) {
         return $rowData;
     }
     if (self::SCOPE_DEFAULT == $this->getRowScope($rowData)) {
         $lastSku = $rowData[self::COL_SKU];
     }
     if (isset($this->_oldSku[$lastSku])) {
         $rowData[self::COL_ATTR_SET] = $this->_newSku[$lastSku]['attr_set_code'];
         $rowData[self::COL_TYPE] = $this->_newSku[$lastSku]['type_id'];
     }
     return $rowData;
 }
 /**
  * Is attribute contains particular data (not plain entity attribute).
  *
  * @param string $attrCode
  * @return bool
  */
 public function isAttributeParticular($attrCode)
 {
     return parent::isAttributeParticular($attrCode) || $this->_addressEntity->isAttributeParticular($attrCode);
 }
Exemple #5
0
 /**
  * Constructor.
  *
  * @param Mage_ImportExport_Model_Import_Entity_Customer $customer
  * @return void
  */
 public function __construct(Mage_ImportExport_Model_Import_Entity_Customer $customer)
 {
     parent::__construct();
     $this->_initAttributes()->_initCountryRegions();
     $this->_entityTable = Mage::getModel('customer/address')->getResource()->getEntityTable();
     $this->_customer = $customer;
     foreach ($this->_messageTemplates as $errorCode => $message) {
         $this->_customer->addMessageTemplate($errorCode, $message);
     }
 }
Exemple #6
0
 /**
  * Test for method validateData()
  *
  * @covers Mage_ImportExport_Model_Import_Entity_Abstract::validateData
  * @expectedException Mage_Core_Exception
  * @expectedExceptionMessage Column names: "%s" are invalid
  */
 public function testValidateDataAttributeNames()
 {
     $this->_createDataHelperMock();
     $this->_createSourceAdapterMock(array('_test1'));
     $this->_model->validateData();
 }
Exemple #7
0
 /**
  * Constructor.
  *
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->_initWebsites()->_initStores()->_initAttributeSets()->_initTypeModels()->_initCategories()->_initSkus()->_initCustomerGroups();
 }
 /**
  * Set valid attribute set and category type to rows with all scopes
  * to ensure that existing Categories doesn't changed.
  *
  * @param array $rowData
  * @return array
  */
 protected function _prepareRowForDb(array $rowData)
 {
     $rowData = parent::_prepareRowForDb($rowData);
     if (Mage_ImportExport_Model_Import::BEHAVIOR_DELETE == $this->getBehavior()) {
         return $rowData;
     }
     if (self::SCOPE_DEFAULT == $this->getRowScope($rowData)) {
         $rowData['name'] = $this->_getCategoryName($rowData);
         if (!isset($rowData['position'])) {
             $rowData['position'] = 10000;
         }
         // diglin - prevent warning message
     }
     return $rowData;
 }
 public function __construct()
 {
     parent::__construct();
     $this->_initStores()->_initCustomers()->_initSublogins();
     $this->_entityTable = Mage::getModel('customer/customer')->getResource()->getTable('sublogin/sublogin');
 }