本文整理汇总了PHP中Varien_Io_File::streamReadCsv方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Io_File::streamReadCsv方法的具体用法?PHP Varien_Io_File::streamReadCsv怎么用?PHP Varien_Io_File::streamReadCsv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Io_File
的用法示例。
在下文中一共展示了Varien_Io_File::streamReadCsv方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseCsv
/**
* Parses csv file
*
* @param string $file
* @return Mage_Core_Model_Resource_Abstract
*/
public function parseCsv($file)
{
$info = pathinfo($file);
$io = new Varien_Io_File();
$io->open(array('path' => $info['dirname']));
$io->streamOpen($info['basename'], 'r');
$headers = $io->streamReadCsv();
if ($headers === false) {
$io->streamClose();
Mage::throwException(Mage::helper('pyro_licenses')->__('You must specify valid headers in the first row'));
}
if (false === ($columns = $this->_prepareColumns($headers))) {
$io->streamClose();
Mage::throwException(Mage::helper('pyro_licenses')->__("Invalid header: 'License' is missed"));
}
$this->_write->beginTransaction();
try {
$rowNumber = 1;
$importData = array();
while (false !== ($csvLine = $io->streamReadCsv())) {
$rowNumber++;
// check for empty lines
$emptyLine = array_unique($csvLine);
if (count($emptyLine) == 1 && $emptyLine[0] == "") {
continue;
}
$row = $this->_getImportRow($csvLine, $columns, $rowNumber);
if ($row !== false) {
$importData[] = $row;
}
if (count($importData) == 5000) {
$this->_saveImportData($importData);
$importData = array();
}
}
$this->_saveImportData($importData);
$io->streamClose();
} catch (Mage_Core_Exception $e) {
$this->_write->rollback();
$io->streamClose();
Mage::throwException($e->getMessage());
} catch (Exception $e) {
$this->_write->rollback();
$io->streamClose();
Mage::logException($e);
Mage::throwException(Mage::helper('adminhtml')->__($e->getMessage()));
}
$this->_write->commit();
if ($this->_importErrors) {
$error = sprintf('ImportSubscribers: "%1$s"', implode('", "', $this->_importErrors));
Mage::log($error, 3, '', true);
}
return $this;
}
示例2: getPatchefiles
public function getPatchefiles()
{
/* Mage::getBaseDir('etc') . DS . 'applied.patches.list'; */
$path = BP . DS . "app" . DS . "etc" . DS;
$filename = 'applied.patches.list';
$filepath = $path . $filename;
if (!file_exists($filepath)) {
return "No Patch file found.";
}
if (!is_readable($filepath)) {
return "Patch file is not readable.";
}
$flocal = new Varien_Io_File();
$flocal->open(array('path' => dirname($filepath)));
$flocal->streamOpen($filepath, 'r');
$patch_install_version = array();
$patch_uninstall_version = array();
$patch_version = array();
while (false !== ($patchFileLines = $flocal->streamReadCsv())) {
if (strpos($patchFileLines[0], 'SUPEE') !== false) {
$patch_name = explode('|', $patchFileLines[0]);
$patch_install_version[] = str_replace("SUPEE-", '', $patch_name[1]);
}
if (strpos($patchFileLines[0], 'REVERTED') !== false) {
$patch_name = explode('|', $patchFileLines[0]);
$patch_uninstall_version[] = str_replace("SUPEE-", '', $patch_name[1]);
}
}
$patch_install_version = array_unique($patch_install_version);
$patch_uninstall_version = array_unique($patch_uninstall_version);
$patch_version = array_diff($patch_install_version, $patch_uninstall_version);
return implode(",", $patch_version);
}
示例3: loadData
/**
* Load the import data from the csv files
*
* @return array
*/
public function loadData()
{
$ioHandler = new Varien_Io_File();
$ioHandler->open(array('path' => $this->getImportDir()));
$debitFiles = $ioHandler->ls(Varien_Io_File::GREP_FILES);
$import = array();
foreach ($debitFiles as $debitFile) {
if ($debitFile['filetype'] != 'csv') {
continue;
}
$country = str_replace('.csv', '', $debitFile['text']);
$country = strtoupper($country);
$import[$country] = array();
$i = 1;
$ioHandler->streamOpen($debitFile['text'], 'r');
while (($line = $ioHandler->streamReadCsv()) !== false) {
if ($i == 1) {
$i++;
continue;
}
// Check if routing number already exists
$swiftCode = trim($line[2]);
if (array_key_exists($swiftCode, $import[$country]) || empty($swiftCode)) {
continue;
}
// Add bank to array
$import[$country][$swiftCode] = array('routing_number' => trim($line[0]), 'swift_code' => $swiftCode, 'bank_name' => trim($line[1]));
}
$ioHandler->streamClose();
}
return $import;
}
示例4: import
/**
* @$forceCreation true overwrites existing entities with the new values
*/
public function import($forceCreation = false)
{
if (is_null($this->_entity)) {
throw Mage::exception('Please specify a valid entity.');
}
if (!file_exists($this->_importFile)) {
throw Mage::exception('Please specify a valid csv file.');
}
if (is_null($this->_storeId)) {
throw Mage::exception('Please specify a valid store.');
}
$io = new Varien_Io_File();
$io->streamOpen($this->_importFile, 'r');
$io->streamLock(true);
$firstLine = true;
while (false !== ($line = $io->streamReadCsv())) {
if ($firstLine) {
$firstLine = false;
$this->_headerColumns = $line;
continue;
}
$data = array();
foreach ($this->_headerColumns as $key => $val) {
$data[$val] = $line[$key];
}
$this->_importEntity($data, $forceCreation);
}
}
示例5: uploadAndImport
public function uploadAndImport(Varien_Object $object)
{
$hlr = Mage::helper("amacart");
if (empty($_FILES['groups']['tmp_name']['import']['fields']['blacklist']['value'])) {
return $this;
}
$csvFile = $_FILES['groups']['tmp_name']['import']['fields']['blacklist']['value'];
$io = new Varien_Io_File();
$info = pathinfo($csvFile);
$io->open(array('path' => $info['dirname']));
$io->streamOpen($info['basename'], 'r');
$emails = array();
while (($csvLine = $io->streamReadCsv()) !== FALSE) {
foreach ($csvLine as $email) {
if (!Zend_Validate::is($email, 'NotEmpty')) {
} else {
if (!Zend_Validate::is($email, 'EmailAddress')) {
$this->_warnings[] = $email . " " . $hlr->__("not valid email");
} else {
$emails[] = array("email" => $email, 'created_at' => date("Y-m-d H:i:s", time()));
}
}
if (count($emails) == 100) {
$this->saveImportData($emails);
$emails = array();
}
}
}
$this->saveImportData($emails);
foreach (array_slice($this->_warnings, 0, 10) as $warning) {
Mage::getSingleton('adminhtml/session')->addWarning($warning);
}
Mage::getSingleton('core/session')->addSuccess($hlr->__("Import completed"));
}
示例6: importAction
public function importAction()
{
try {
$productId = $this->getRequest()->getParam('id');
$fileName = $this->getRequest()->getParam('Filename');
$path = Mage::getBaseDir('var') . DS . 'import' . DS;
$uploader = new Mage_Core_Model_File_Uploader('file');
$uploader->setAllowedExtensions(array('csv'));
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(false);
$result = $uploader->save($path, $fileName);
$io = new Varien_Io_File();
$io->open(array('path' => $path));
$io->streamOpen($path . $fileName, 'r');
$io->streamLock(true);
while ($data = $io->streamReadCsv(';', '"')) {
if ($data[0]) {
$model = Mage::getModel('giftcards/pregenerated')->load($data[0], 'card_code');
if ($model->getId()) {
continue;
}
$model->setCardCode($data[0]);
$model->setCardStatus(1);
$model->setProductId($productId);
$model->save();
} else {
continue;
}
}
} catch (Exception $e) {
$result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
示例7: saveImportAction
public function saveImportAction()
{
$request = $this->getRequest();
$importConfig = new Varien_Object();
$path = '';
$delimiter = $request->getParam('delimiter', false);
$enclosure = $request->getParam('enclosure', false);
$importConfig->setFilePath($path)->setDelimiter($delimiter)->setEnclosure($enclosure);
try {
$file = $_FILES['file']['name'];
$path = Mage::getBaseDir('var') . DS . 'import' . DS;
$uploader = new Varien_File_Uploader('file');
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(false);
$uploader->save($path, $file);
$io = new Varien_Io_File();
$io->open(array('path' => $path));
$io->streamOpen($path . $file, 'r');
$io->streamLock(true);
$map = $io->streamReadCsv($delimiter, $enclosure);
$prodModel = Mage::getSingleton('catalog/product');
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
$db->query('set foreign_key_checks = 0');
while ($data = $io->streamReadCsv($delimiter, $enclosure)) {
$prod = $prodModel->loadByAttribute('sku', $data[2]);
if (!$prod || !$prod->getId()) {
continue;
}
$prices = Mage::getModel('customerprices/prices');
$prices->loadByCustomer($prod->getId(), $data[0], $data[3]);
$prices->setProductId($prod->getId());
$prices->setCustomerId($data[0]);
$prices->setCustomerEmail($data[1]);
$prices->setQty($data[3]);
$prices->setPrice($data[4]);
$prices->setSpecialPrice($data[5]);
$prices->save();
}
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customerprices')->__('Prices where succesfully imported '));
} catch (Mage_Core_Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
} catch (Exception $e) {
//Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customergroupsprice')->__($e->getMessage().'An error occurred while importing prices.'));
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
$this->getResponse()->setRedirect($this->getUrl("*/*/import"));
}
示例8: _afterSave
public function _afterSave()
{
if (empty(@$_FILES['groups']['tmp_name']['svea_general']['fields']['import_customer_addresses']['value'])) {
return $this;
} else {
try {
$csvFile = $_FILES['groups']['tmp_name']['svea_general']['fields']['import_customer_addresses']['value'];
$io = new Varien_Io_File();
$info = pathinfo($csvFile);
$io->open(array('path' => $info['dirname']));
$io->streamOpen($info['basename'], 'r');
// delete all current rows
$resource = Mage::getSingleton('core/resource');
$connection = $resource->getConnection('core_write');
$connection->query("DELETE FROM {$resource->getTableName('svea_webpay/customer_address')}");
// read header
$header = array();
foreach ($io->streamReadCsv(';') as $k => $v) {
$header[$k] = $this->_fileHeaderMapping[$this->_convertCsvString($v)];
}
// Import rows
while ($row = $io->streamReadCsv(';')) {
$row = array_combine($header, $row);
foreach ($row as $k => $v) {
$row[$k] = $this->_convertCsvString($v);
}
if ($row['status'] !== 'Active') {
continue;
}
// Split name into first and last name
foreach ($this->_splitName($row['name']) as $k => $v) {
$row[$k] = $v;
}
unset($row['name']);
$model = Mage::getModel('svea_webpay/customer_address');
$model->setOrgnr($row['nationalIdNumber']);
$model->setCountryCode($row['countryCode']);
$model->setAddress($row);
$model->save();
}
$io->streamClose();
} catch (Exception $e) {
Mage::logException($e);
throw new Mage_Exception(Mage::helper('svea_webpay')->__("Failed to import customer addresses."));
}
}
}
示例9: cronImportAction
public function cronImportAction()
{
$request = $this->getRequest();
$path = $request->getParam('path', false);
$delimiter = $request->getParam('delimiter', ';');
$enclosure = $request->getParam('enclosure', '"');
try {
$io = new Varien_Io_File();
$io->streamOpen(Mage::getBaseDir() . $path, 'r');
$io->streamLock(true);
$map = $io->streamReadCsv($delimiter, $enclosure);
$prodModel = Mage::getSingleton('catalog/product');
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
$db->query('set foreign_key_checks = 0');
$db->query("delete from {$db->getTableName('customerprices_prices')}");
$errors = array();
while ($data = $io->streamReadCsv($delimiter, $enclosure)) {
$prod = $prodModel->loadByAttribute('sku', $data[1]);
if (!$prod || !$prod->getId()) {
continue;
}
$customer = Mage::getModel('customer/customer')->setWebsiteId(1)->loadByEmail($data[0]);
if (!$customer->getId()) {
Mage::log('Customer not exist - ' . $data[0], null, 'Customerprices_import.log');
$errors[] = $data[0];
continue;
}
$prices = Mage::getModel('customerprices/prices');
$prices->setProductId($prod->getId());
$prices->setCustomerEmail($data[0]);
$prices->setCustomerId($customer->getId());
$prices->setQty($data[2]);
$prices->setPrice($data[3]);
$prices->setSpecialPrice($data[4]);
$prices->save();
}
echo 'FINISHED' . "\n";
if (count($errors)) {
echo "Check Customerprices_import.log for errors";
}
} catch (Mage_Core_Exception $e) {
echo $e->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例10: saveAction
public function saveAction()
{
$request = $this->getRequest();
$path = '';
$delimiter = $request->getParam('delimiter', false);
$enclosure = $request->getParam('enclosure', false);
try {
$file = $_FILES['file']['name'];
$path = Mage::getBaseDir('var') . DS . 'import' . DS;
$uploader = new Varien_File_Uploader('file');
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(false);
$uploader->save($path, $file);
$io = new Varien_Io_File();
$io->open(array('path' => $path));
$io->streamOpen($path . $file, 'r');
$io->streamLock(true);
$map = $io->streamReadCsv($delimiter, $enclosure);
while ($data = $io->streamReadCsv($delimiter, $enclosure)) {
if ($data[0]) {
$model = Mage::getModel('giftcards/giftcards');
$model->setCardAmount($data[1]);
$model->setCardCode($data[0]);
$model->setCardStatus(1);
$model->save();
} else {
continue;
}
}
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('giftcards')->__('Gift Cards where succesfully imported '));
} catch (Mage_Core_Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('giftcards')->__($e->getMessage() . 'An error occurred while importing Gift Cards.'));
}
$this->getResponse()->setRedirect($this->getUrl("*/*/index"));
}
示例11: getBankByBlz
/**
* Returns the bankname by given blz
*
* @param string $blz BLZ
* @return null|string Bank Name
*/
public function getBankByBlz($blz)
{
$data = $this->_loadBlzCache();
if (!$data) {
// open blz file handle
$file = new Varien_Io_File();
$file->open(array('path' => Mage::getModuleDir('etc', 'Itabs_Debit')));
$file->streamOpen('bankleitzahlen.csv', 'r');
// read csv stream
while (($line = $file->streamReadCsv(';')) !== false) {
$data[$line[0]] = $line[1];
}
$this->_saveBlzCache(serialize($data));
} else {
$data = unserialize($data);
}
return empty($data[$blz]) ? null : $data[$blz];
}
示例12: uploadAndImport
/**
* Upload store csv file and import data from it
*
* @throws Mage_Core_Exception
* @param Varien_Object $object
* @return Bluehorse_Storelocator_Model_Storelocator
*/
public function uploadAndImport($object)
{
$this->_behavior = $object->getRequest()->getPost('behavior');
$importFile = $_FILES['import_file'];
if (empty($importFile['tmp_name'])) {
return;
}
$csvFile = $importFile['tmp_name'];
$this->_importErrors = array();
$this->_importedRows = 0;
$io = new Varien_Io_File();
$info = pathinfo($csvFile);
$io->open(array('path' => $info['dirname']));
$io->streamOpen($info['basename'], 'r');
// check and skip headers
$headers = $io->streamReadCsv();
if ($headers === false || count($headers) < 19) {
$io->streamClose();
Mage::throwException(Mage::helper('bluehorse_storelocator')->__('Invalid Stores File Format'));
}
$adapter = $this->_getWriteAdapter();
$adapter->beginTransaction();
try {
$rowNumber = 1;
$importData = array();
while (false !== ($csvLine = $io->streamReadCsv())) {
$rowNumber++;
if (empty($csvLine)) {
continue;
}
$row = $this->_getImportRow($csvLine, $rowNumber);
if ($row !== false) {
$importData[] = $row;
}
if (count($importData) == 5000) {
$this->_saveImportData($importData);
$importData = array();
}
}
if ($this->_importErrors) {
$error = Mage::helper('bluehorse_storelocator')->__('File has not been imported. See the following list of errors: <br>%s', implode(" <br>", $this->_importErrors));
Mage::throwException($error);
}
if (empty($this->_importErrors)) {
$this->_saveImportData($importData);
}
$io->streamClose();
} catch (Mage_Core_Exception $e) {
$adapter->rollback();
$io->streamClose();
Mage::throwException($e->getMessage());
} catch (Exception $e) {
$adapter->rollback();
$io->streamClose();
Mage::logException($e);
Mage::throwException(Mage::helper('bluehorse_storelocator')->__('An error occurred while import stores csv.'));
}
$adapter->commit();
//add success message
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('bluehorse_storelocator')->__($this->_importedRows . ' - Rows imported successfully.'));
return $this;
}
示例13: loadfileAction
//.........这里部分代码省略.........
$i++;
}
$rtn["places"][$i]['label'] = "Manage Local Stock";
$rtn["places"][$i]['value'] = "manage_local_stock";
$rtn["places"][$i]['id'] = 'manage_local_stock';
$rtn["places"][$i]['style'] = "manage_local_stock";
$i++;
}
if ($this->getRequest()->getParam('autoSetInStock') == "0") {
$rtn["places"][$i]['label'] = "Stock status";
$rtn["places"][$i]['value'] = "is_in_stock";
$rtn["places"][$i]['id'] = 'is_in_stock';
$rtn["places"][$i]['style'] = "is_in_stock";
$i++;
}
/* if ($this->getRequest()->getParam('autoSetManageStock') == "0") {
$rtn["places"][$i]['label'] = "Manage stock";
$rtn["places"][$i]['value'] = "manage_stock";
$rtn["places"][$i]['id'] = 'manage_stock';
$rtn["places"][$i]['style'] = "manage_stock";
$i++;
} */
// if total stock are not sync with local stocks or if total stock are sync with local stocks but sync is done by user
if ($this->getRequest()->getParam('autoSetTotal') == "0") {
$rtn["places"][$i]['label'] = "Total Stock";
$rtn["places"][$i]['value'] = "total";
$rtn["places"][$i]['id'] = 'total';
$rtn["places"][$i]['style'] = "total";
$i++;
} else {
$rtn["places"][$i]['label'] = "used";
$rtn["places"][$i]['value'] = "used";
$rtn["places"][$i]['id'] = 'used';
$rtn["places"][$i]['style'] = "used";
$i++;
}
$resource = Mage::getSingleton('core/resource');
$read = $resource->getConnection('core_read');
$tableEet = $resource->getTableName('eav_entity_type');
$select = $read->select()->from($tableEet)->where('entity_type_code=\'catalog_product\'');
$data = $read->fetchAll($select);
$typeId = $data[0]['entity_type_id'];
function cmp($a, $b)
{
return $a['attribute_code'] < $b['attribute_code'] ? -1 : 1;
}
/* Liste des attributs disponible dans la bdd */
$attributesList = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($typeId)->addSetInfo()->getData();
usort($attributesList, "cmp");
foreach ($attributesList as $attribute) {
if (!empty($attribute['frontend_label'])) {
$rtn["places"][$i]['label'] = $attribute['attribute_code'];
$rtn["places"][$i]['value'] = $attribute['attribute_code'];
$rtn["places"][$i]['id'] = "attribute-" . $attribute['attribute_code'] . "-" . $attribute['attribute_id'] . "-" . $attribute['backend_type'];
$rtn["places"][$i]['style'] = "attribute";
$i++;
}
}
$rtn["places"][$i]['label'] = "not used";
$rtn["places"][$i]['value'] = "not-used";
$rtn["places"][$i]['id'] = 'not-used';
$rtn["places"][$i]['style'] = "not-used";
$i++;
$sku_offset = $this->getRequest()->getParam('skuOffset');
$offset = $sku_offset - 1;
$l = 0;
if ($fileEnclosure != "none") {
while (false !== ($csvLine = $io->streamReadCsv($fileSeparator, $fileEnclosure)) && $l < 1000) {
$skus = array_splice($csvLine, $offset, 1);
array_unshift($csvLine, $skus[0]);
if (strlen($csvLine[0]) > 50) {
$csvLine[0] = '<span title="' . $csvLine[0] . '">' . substr($csvLine[0], 0, 50) . '...' . '</span>';
}
$rtn['body'][$l] = $csvLine;
$rtn['body'][$l][] = 0;
$l++;
}
} else {
while (false !== ($csvLine = $io->streamReadCsv($fileSeparator)) && $l < 1000) {
$skus = array_splice($csvLine, $offset, 1);
array_unshift($csvLine, $skus[0]);
if (strlen($csvLine[0]) > 50) {
$csvLine[0] = '<span title="' . $csvLine[0] . '">' . substr($csvLine[0], 0, 50) . '...' . '</span>';
}
$rtn['body'][$l] = $csvLine;
$rtn['body'][$l][] = 0;
$l++;
}
}
$io->streamClose();
if ($this->getRequest()->getParam('useCustomRules')) {
$rules = $this->getRequest()->getParam('customRules');
foreach ($rtn['body'] as $i => $line) {
eval(str_replace('$C[', '$line[', $rules));
$rtn['body'][$i] = $line;
}
}
}
die(json_encode($rtn));
}
示例14: importvalidateAction
public function importvalidateAction()
{
$this->_validateCustomerLogin();
$session = $this->_getSession();
$this->_initLayoutMessages('marketplace/session');
$data = $this->getRequest()->getPost();
$time = time();
if ($data) {
try {
$marketplaceHelper = Mage::helper('marketplace');
$customer = Mage::getSingleton('customer/session')->getCustomer();
$productState = $customer->getSellerProductState();
$productStatus = $customer->getSellerProductStatus();
$newProductStatus = $productStatus ? $productStatus : $marketplaceHelper->getNewProductStatus();
$newProductState = $productState ? $productState : $marketplaceHelper->getNewProductState();
$newProductStateValue = Mage::getModel('eav/config')->getAttribute('catalog_product', 'marketplace_state')->getSource()->getOptionText($newProductState);
$this->loadLayout();
/** @var $import Mage_ImportExport_Model_Import */
$import = Mage::getModel('importexport/import');
$source = $import->setData($data)->uploadSource();
// Modify CSV file
$io = new Varien_Io_File();
$io->streamOpen($source, 'r');
$io->streamLock(true);
$newCsvData = array();
$i = 0;
while ($data = $io->streamReadCsv()) {
if ($i == 0) {
$data[] = '_attribute_set';
$data[] = '_type';
$data[] = '_product_websites';
$data[] = 'tax_class_id';
$data[] = 'visibility';
$data[] = 'seller_id';
$data[] = 'marketplace_state';
$data[] = 'status';
$data[] = 'media_gallery';
$newCsvData[] = $data;
} else {
$data[] = 'Default';
$data[] = Mage_Catalog_Model_Product_Type::DEFAULT_TYPE;
$data[] = 'base';
$data[] = 0;
$data[] = $marketplaceHelper->getNewProductVisibility();
$data[] = $customer->getCompanyName();
$data[] = $newProductStateValue;
$data[] = $newProductStatus;
$data[] = ' ';
if ($this->validateSellerCSV($data)) {
$newCsvData[] = $data;
}
}
$i++;
}
$io->close();
unlink($source);
$checkPath = Mage::getBaseDir() . DS . 'media' . DS . 'marketplace/' . $customer->getId();
if (!file_exists($checkPath)) {
mkdir($checkPath, 0777);
}
$newSource = $checkPath . DS . 'productimport.csv';
$io = new Varien_File_Csv();
$io->saveData($newSource, $newCsvData);
$validationResult = $import->validateSource($newSource);
if (!$import->getProcessedRowsCount()) {
$session->addError($this->__('File does not contain data or duplicate sku. Please upload another one'));
} else {
if (!$validationResult) {
if ($import->getProcessedRowsCount() == $import->getInvalidRowsCount()) {
$session->addNotice($this->__('File is totally invalid. Please fix errors and re-upload file'));
} elseif ($import->getErrorsCount() >= $import->getErrorsLimit()) {
$session->addNotice($this->__('Errors limit (%d) reached. Please fix errors and re-upload file', $import->getErrorsLimit()));
} else {
if ($import->isImportAllowed()) {
$session->addNotice($this->__('Please fix errors and re-upload file or simply press "Import" button to skip rows with errors'), true);
} else {
$session->addNotice($this->__('File is partially valid, but import is not possible'), false);
}
}
// errors info
foreach ($import->getErrors() as $errorCode => $rows) {
$error = $errorCode . ' ' . $this->__('in rows:') . ' ' . implode(', ', $rows);
$session->addError($error);
}
} else {
if ($import->isImportAllowed()) {
$import->importSource();
//Process Images
$status = $this->_uploadZipImages($time);
if ($status !== false) {
if ($status[0] == 'success') {
$returnVal = Mage::getModel('marketplace/image')->process($newCsvData, $customer->getId(), $time);
if ($returnVal === true) {
$customDir = Mage::getBaseDir() . DS . 'media' . DS . 'marketplace' . DS . $customer->getId() . DS . $time;
self::delTree($customDir);
}
$session->addSuccess($this->__($status[1]), true);
} else {
$session->addError($this->__($status[1]));
}
//.........这里部分代码省略.........
示例15: generateXml
public function generateXml()
{
$x147 = "str_replace";
$x148 = "utf8_encode";
$x149 = "preg_match_all";
$x14a = "preg_match";
$x14b = "is_null";
$x14c = "number_format";
$x14d = "is_numeric";
$x14e = "preg_split";
$x14f = "utf8_decode";
$x150 = "is_string";
$x151 = "json_decode";
$x152 = "is_array";
$x153 = "array_push";
$x154 = "print_r";
$x155 = "version_compare";
$x156 = "in_array";
$x157 = "array_pop";
$x158 = "str_pad";
$x159 = "array_shift";
$x15a = "array_reverse";
$x15b = "array_values";
$x15c = "preg_replace";
$x15d = "strip_tags";
$x15e = "html_entity_decode";
$x15f = "mb_strtolower";
$x160 = "mb_strtoupper";
Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> --------------- START PROCESS FOR " . strtoupper($this->x165(false)) . "-----------------", null, $this->x165('.log'));
ini_set('memory_limit', Mage::getStoreConfig("simplegoogleshopping/system/memory_limit") . 'M');
$this->_debug = isset($_GET['debug']) ? true : false;
include Mage::getBaseDir() . "/lib/Wyomind/Google/Requirements.php";
$x3a = new Varien_Io_File();
$x4f = new Varien_Io_File();
$x52 = Mage::getBaseDir() . DS . 'var' . DS . 'tmp' . DS;
$x53 = $x52 . "sgs_" . $this->getSimplegoogleshoppingId() . ".flag";
$x3a->setAllowCreateFolders(true);
if (!$this->_display) {
$x3a->open(array('path' => $this->getPath()));
if ($x3a->fileExists($this->x165()) && !$x3a->isWriteable($this->x165())) {
Mage::throwException(Mage::helper('simplegoogleshopping')->__('File "\\x25\\x73" cannot be saved. Please, make sure the directory "\\x25\\x73" is writeable by web server.', $this->x165(), $this->getPath()));
}
$x3a->streamOpen($this->x165());
$x4f->open(array('path' => $x52));
if ($x4f->fileExists($x53, false)) {
$x4f->streamOpen($x53, 'r');
$x4d = $x4f->streamReadCsv(";");
$x54 = $x4f->streamStat();
if ($x4d[0] == "PROCESSING") {
$x55 = $x54["mtime"];
$x56 = $x4d[3];
if (!(Mage::getSingleton('core/date')->gmtTimestamp() > $x55 + $x56 * 10 || Mage::getSingleton('core/date')->gmtTimestamp() > $x55 + $x56 * 2)) {
Mage::throwException(Mage::helper('simplegoogleshopping')->__('File "\\x25\\x73" is already processing. Please wait the end of the process.', $this->x165(), $this->getPath()));
}
}
} else {
$x4f->streamOpen($x53);
}
}
$x57 = array("ac" => "activation_code", "ak" => "activation_key", "bu" => "base_url", "md" => "md5", "th" => "this", "dm" => "_demo", "ext" => "sgs", "ver" => "9.0.1");
$x150(Mage::app()->getRequest()->getParam("store_id")) ? $x58 = Mage::app()->getRequest()->getParam("store_id") : ($x58 = $this->getStoreId());
$x59 = Mage::getSingleton('core/date')->gmtDate('Y-m-d');
$x5a = Mage::getDesign()->getSkinUrl();
$x5b = Mage::getStoreConfig("catalog/placeholder/image_placeholder", $x58);
$x5c = Mage::getStoreConfig("currency/options/base", $x58);
$x5d = Mage::getStoreConfig("cataloginventory/item_options/manage_stock", $x58);
$x5e = Mage::getStoreConfig("cataloginventory/item_options/backorders", $x58);
$x5f = Mage::app()->getStore($x58)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false);
$x60 = Mage::getModel('core/store')->load($x58)->getBaseUrl();
$x61 = Mage::app()->getStore($x58)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA, false);
$x62 = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $x58);
$x63 = Mage::app()->getStore($x58)->getRootCategoryId();
$x64 = Mage::app()->getStore()->getStoreId();
$x65 = array("activation_key" => Mage::getStoreConfig("simplegoogleshopping/license/activation_key"), "activation_code" => Mage::getStoreConfig("simplegoogleshopping/license/activation_code"), "base_url" => Mage::getStoreConfig("web/secure/base_url"));
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_xmlitempattern")) ? $x66 = Mage::app()->getRequest()->getParam("simplegoogleshopping_xmlitempattern") : ($x66 = $this->getSimplegoogleshoppingXmlitempattern());
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_title")) ? $x67 = Mage::app()->getRequest()->getParam("simplegoogleshopping_title") : ($x67 = $this->getSimplegoogleshoppingTitle());
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_description")) ? $x68 = Mage::app()->getRequest()->getParam("simplegoogleshopping_description") : ($x68 = $this->getSimplegoogleshoppingDescription());
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_categories")) ? $x69 = $x151(Mage::app()->getRequest()->getParam("simplegoogleshopping_categories")) : ($x69 = $x151($this->getSimplegoogleshoppingCategories()));
$x150(Mage::app()->getRequest()->getParam("category_filter")) ? $x6a = Mage::app()->getRequest()->getParam("category_filter") : ($x6a = $this->getSimplegoogleshoppingCategoryFilter());
$x150(Mage::app()->getRequest()->getParam("category_type")) ? $x6b = Mage::app()->getRequest()->getParam("category_type") : ($x6b = $this->getSimplegoogleshoppingCategoryType());
$x6c = array();
$x6d = array();
if ($x152($x69)) {
foreach ($x69 as $x6e) {
if ($x6e->checked) {
$x6c[] = $x6e->line;
}
}
foreach ($x69 as $x6e) {
if ($x6e->mapping != "") {
$x6d[$x6e->line] = $x6e->mapping;
}
}
}
if (count($x6c) < 1) {
$x6c[] = '*';
}
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_type_ids")) ? $x6f = explode(',', Mage::app()->getRequest()->getParam("simplegoogleshopping_type_ids")) : ($x6f = explode(',', $this->getSimplegoogleshoppingTypeIds()));
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_visibility")) ? $x70 = explode(',', Mage::app()->getRequest()->getParam("simplegoogleshopping_visibility")) : ($x70 = explode(',', $this->getSimplegoogleshoppingVisibility()));
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_attributes")) ? $x71 = $x151(Mage::app()->getRequest()->getParam("simplegoogleshopping_attributes")) : ($x71 = $x151($this->getSimplegoogleshoppingAttributes()));
//.........这里部分代码省略.........