Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_ImportExport_Adminhtml_ExportController
  • Mage_ImportExport_Adminhtml_ImportController
  • Mage_ImportExport_Block_Adminhtml_Export_Edit
  • Mage_ImportExport_Block_Adminhtml_Export_Edit_Form
  • Mage_ImportExport_Block_Adminhtml_Export_Filter
  • Mage_ImportExport_Block_Adminhtml_Import_Edit
  • Mage_ImportExport_Block_Adminhtml_Import_Edit_Form
  • Mage_ImportExport_Block_Adminhtml_Import_Frame_Result
  • Mage_ImportExport_Helper_Data
  • Mage_ImportExport_Model_Abstract
  • Mage_ImportExport_Model_Config
  • Mage_ImportExport_Model_Export
  • Mage_ImportExport_Model_Export_Adapter_Abstract
  • Mage_ImportExport_Model_Export_Adapter_Csv
  • Mage_ImportExport_Model_Export_Entity_Abstract
  • Mage_ImportExport_Model_Export_Entity_Customer
  • Mage_ImportExport_Model_Export_Entity_Product
  • Mage_ImportExport_Model_Export_Entity_Product_Type_Abstract
  • Mage_ImportExport_Model_Export_Entity_Product_Type_Configurable
  • Mage_ImportExport_Model_Export_Entity_Product_Type_Grouped
  • Mage_ImportExport_Model_Export_Entity_Product_Type_Simple
  • Mage_ImportExport_Model_Import
  • Mage_ImportExport_Model_Import_Adapter
  • Mage_ImportExport_Model_Import_Adapter_Abstract
  • Mage_ImportExport_Model_Import_Adapter_Csv
  • Mage_ImportExport_Model_Import_Entity_Abstract
  • Mage_ImportExport_Model_Import_Entity_Customer
  • Mage_ImportExport_Model_Import_Entity_Customer_Address
  • Mage_ImportExport_Model_Import_Entity_Product
  • Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract
  • Mage_ImportExport_Model_Import_Entity_Product_Type_Configurable
  • Mage_ImportExport_Model_Import_Entity_Product_Type_Grouped
  • Mage_ImportExport_Model_Import_Entity_Product_Type_Simple
  • Mage_ImportExport_Model_Import_Proxy_Product
  • Mage_ImportExport_Model_Import_Proxy_Product_Resource
  • Mage_ImportExport_Model_Import_Uploader
  • Mage_ImportExport_Model_Mysql4_Import_Data
  • Mage_ImportExport_Model_Mysql4_Setup
  • Mage_ImportExport_Model_Resource_Import_Data
  • Mage_ImportExport_Model_Resource_Setup
  • Mage_ImportExport_Model_Source_Export_Entity
  • Mage_ImportExport_Model_Source_Export_Format
  • Mage_ImportExport_Model_Source_Import_Behavior
  • Mage_ImportExport_Model_Source_Import_Entity
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_ImportExport
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Import controller
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_ImportExport
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_ImportExport_Adminhtml_ImportController extends Mage_Adminhtml_Controller_Action
 35: {
 36:     /**
 37:      * Custom constructor.
 38:      *
 39:      * @return void
 40:      */
 41:     protected function _construct()
 42:     {
 43:         // Define module dependent translate
 44:         $this->setUsedModuleName('Mage_ImportExport');
 45:     }
 46: 
 47:     /**
 48:      * Initialize layout.
 49:      *
 50:      * @return Mage_ImportExport_Adminhtml_ImportController
 51:      */
 52:     protected function _initAction()
 53:     {
 54:         $this->_title($this->__('Import/Export'))
 55:             ->loadLayout()
 56:             ->_setActiveMenu('system/importexport');
 57: 
 58:         return $this;
 59:     }
 60: 
 61:     /**
 62:      * Check access (in the ACL) for current user.
 63:      *
 64:      * @return bool
 65:      */
 66:     protected function _isAllowed()
 67:     {
 68:         return Mage::getSingleton('admin/session')->isAllowed('system/convert/import');
 69:     }
 70: 
 71:     /**
 72:      * Index action.
 73:      *
 74:      * @return void
 75:      */
 76:     public function indexAction()
 77:     {
 78:         $maxUploadSize = Mage::helper('importexport')->getMaxUploadSize();
 79:         $this->_getSession()->addNotice(
 80:             $this->__('Total size of uploadable files must not exceed %s', $maxUploadSize)
 81:         );
 82:         $this->_initAction()
 83:             ->_title($this->__('Import'))
 84:             ->_addBreadcrumb($this->__('Import'), $this->__('Import'));
 85: 
 86:         $this->renderLayout();
 87:     }
 88: 
 89:     /**
 90:      * Start import process action.
 91:      *
 92:      * @return void
 93:      */
 94:     public function startAction()
 95:     {
 96:         $data = $this->getRequest()->getPost();
 97:         if ($data) {
 98:             $this->loadLayout(false);
 99: 
100:             /** @var $resultBlock Mage_ImportExport_Block_Adminhtml_Import_Frame_Result */
101:             $resultBlock = $this->getLayout()->getBlock('import.frame.result');
102:             /** @var $importModel Mage_ImportExport_Model_Import */
103:             $importModel = Mage::getModel('importexport/import');
104: 
105:             try {
106:                 $importModel->importSource();
107:                 $importModel->invalidateIndex();
108:                 $resultBlock->addAction('show', 'import_validation_container')
109:                     ->addAction('innerHTML', 'import_validation_container_header', $this->__('Status'));
110:             } catch (Exception $e) {
111:                 $resultBlock->addError($e->getMessage());
112:                 $this->renderLayout();
113:                 return;
114:             }
115:             $resultBlock->addAction('hide', array('edit_form', 'upload_button', 'messages'))
116:                 ->addSuccess($this->__('Import successfully done.'));
117:             $this->renderLayout();
118:         } else {
119:             $this->_redirect('*/*/index');
120:         }
121:     }
122: 
123:     /**
124:      * Validate uploaded files action.
125:      *
126:      * @return void
127:      */
128:     public function validateAction()
129:     {
130:         $data = $this->getRequest()->getPost();
131:         if ($data) {
132:             $this->loadLayout(false);
133:             /** @var $resultBlock Mage_ImportExport_Block_Adminhtml_Import_Frame_Result */
134:             $resultBlock = $this->getLayout()->getBlock('import.frame.result');
135:             // common actions
136:             $resultBlock->addAction('show', 'import_validation_container')
137:                 ->addAction('clear', array(
138:                     Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE,
139:                     Mage_ImportExport_Model_Import::FIELD_NAME_IMG_ARCHIVE_FILE)
140:                 );
141: 
142:             try {
143:                 /** @var $import Mage_ImportExport_Model_Import */
144:                 $import = Mage::getModel('importexport/import');
145:                 $validationResult = $import->validateSource($import->setData($data)->uploadSource());
146: 
147:                 if (!$import->getProcessedRowsCount()) {
148:                     $resultBlock->addError($this->__('File does not contain data. Please upload another one'));
149:                 } else {
150:                     if (!$validationResult) {
151:                         if ($import->getProcessedRowsCount() == $import->getInvalidRowsCount()) {
152:                             $resultBlock->addNotice(
153:                                 $this->__('File is totally invalid. Please fix errors and re-upload file')
154:                             );
155:                         } elseif ($import->getErrorsCount() >= $import->getErrorsLimit()) {
156:                             $resultBlock->addNotice(
157:                                 $this->__(
158:                                     'Errors limit (%d) reached. Please fix errors and re-upload file',
159:                                     $import->getErrorsLimit()
160:                                 )
161:                             );
162:                         } else {
163:                             if ($import->isImportAllowed()) {
164:                                 $resultBlock->addNotice(
165:                                     $this->__('Please fix errors and re-upload file or simply press "Import" button to skip rows with errors'),
166:                                     true
167:                                 );
168:                             } else {
169:                                 $resultBlock->addNotice(
170:                                     $this->__('File is partially valid, but import is not possible'), false
171:                                 );
172:                             }
173:                         }
174:                         // errors info
175:                         foreach ($import->getErrors() as $errorCode => $rows) {
176:                             $error = $errorCode . ' ' . $this->__('in rows:') . ' ' . implode(', ', $rows);
177:                             $resultBlock->addError($error);
178:                         }
179:                     } else {
180:                         if ($import->isImportAllowed()) {
181:                             $resultBlock->addSuccess(
182:                                 $this->__('File is valid! To start import process press "Import" button'), true
183:                             );
184:                         } else {
185:                             $resultBlock->addError(
186:                                 $this->__('File is valid, but import is not possible'), false
187:                             );
188:                         }
189:                     }
190:                     $resultBlock->addNotice($import->getNotices());
191:                     $resultBlock->addNotice(
192:                         $this->__(
193:                             'Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d',
194:                             $import->getProcessedRowsCount(), $import->getProcessedEntitiesCount(),
195:                             $import->getInvalidRowsCount(), $import->getErrorsCount()
196:                         )
197:                     );
198:                 }
199:             } catch (Exception $e) {
200:                 $resultBlock->addNotice($this->__('Please fix errors and re-upload file'))
201:                     ->addError($e->getMessage());
202:             }
203:             $this->renderLayout();
204:         } elseif ($this->getRequest()->isPost() && empty($_FILES)) {
205:             $this->loadLayout(false);
206:             $resultBlock = $this->getLayout()->getBlock('import.frame.result');
207:             $resultBlock->addError($this->__('File was not uploaded'));
208:             $this->renderLayout();
209:         } else {
210:             $this->_getSession()->addError($this->__('Data is invalid or file is not uploaded'));
211:             $this->_redirect('*/*/index');
212:         }
213:     }
214: }
215: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0