00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Dataflow 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 00028 /** 00029 * Dataflow Batch abstract model 00030 * 00031 * @category Mage 00032 * @package Mage_Dataflow 00033 * @author Magento Core Team <core@magentocommerce.com> 00034 */ 00035 abstract class Mage_Dataflow_Model_Batch_Abstract extends Mage_Core_Model_Abstract 00036 { 00037 /** 00038 * Set batch data 00039 * automatic convert to serialize data 00040 * 00041 * @param mixed $data 00042 * @return Mage_Dataflow_Model_Batch_Abstract 00043 */ 00044 public function setBatchData($data) 00045 { 00046 /** 00047 * need prepare valid utf-8 data 00048 * related with php bug #42588 00049 */ 00050 foreach ($data as $key=>$value) { 00051 $str = @iconv("utf-8", "utf-8//IGNORE", $value); 00052 if ($str) { 00053 $data[$key] = $str; 00054 } 00055 } 00056 $this->setData('batch_data', serialize($data)); 00057 return $this; 00058 } 00059 00060 /** 00061 * Retrieve batch data 00062 * return unserialize data 00063 * 00064 * @return mixed 00065 */ 00066 public function getBatchData() 00067 { 00068 $data = $this->_data['batch_data']; 00069 $data = unserialize($data); 00070 return $data; 00071 } 00072 00073 /** 00074 * Retrieve id collection 00075 * 00076 * @param int $batchId 00077 * @return array 00078 */ 00079 public function getIdCollection($batchId = null) 00080 { 00081 if (!is_null($batchId)) { 00082 $this->setBatchId($batchId); 00083 } 00084 return $this->getResource()->getIdCollection($this); 00085 } 00086 00087 public function deleteCollection($batchId = null) 00088 { 00089 if (!is_null($batchId)) { 00090 $this->setBatchId($batchId); 00091 } 00092 return $this->getResource()->deleteCollection($this); 00093 } 00094 }