• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Varien_File_Csv类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Varien_File_Csv的典型用法代码示例。如果您正苦于以下问题:PHP Varien_File_Csv类的具体用法?PHP Varien_File_Csv怎么用?PHP Varien_File_Csv使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Varien_File_Csv类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getExtensions

 public function getExtensions()
 {
     $data = array();
     try {
         $file = 'http://d52ndf1ixk2tu.cloudfront.net/media/featured_product.csv';
         /* https does not work */
         $content = $this->urlGetContents($file);
         if ($content == false) {
             $file = 'https://www.iwdagency.com/extensions/media/featured_product.csv';
             $content = $this->urlGetContents($file);
             if ($content == false) {
                 return "";
             }
         }
         $path = Mage::getBaseDir('media') . DS . 'import' . DS . 'featured_product.csv';
         if (!file_exists(Mage::getBaseDir('media') . DS . 'import')) {
             mkdir(Mage::getBaseDir('media') . DS . 'import');
         }
         file_put_contents($path, $content);
         $csv = new Varien_File_Csv();
         $data = $csv->getData($path);
         @unlink($path);
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return $data;
 }
开发者ID:newedge-media,项目名称:iwantmymeds,代码行数:27,代码来源:Jsinit.php


示例2: saveAction

 public function saveAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         $file_path = Mage::getBaseDir() . '/media/enquiryform/' . str_replace(' ', "_", $data['name']) . '_' . date("d_m_Y_H_i_s") . '.csv';
         $mage_csv = new Varien_File_Csv();
         $mage_csv->saveData($file_path, $data);
         exit;
         $model = Mage::getModel('eventmanager/eventmanagercustom');
         $model->setData($data)->setId($this->getRequest()->getParam('id'));
         try {
             if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
                 $model->setCreatedTime(now())->setUpdateTime(now());
             } else {
                 $model->setUpdateTime(now());
             }
             $model->save();
             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('eventmanager')->__('Custom event request was successfully saved'));
             Mage::getSingleton('adminhtml/session')->setFormData(false);
             if ($this->getRequest()->getParam('back')) {
                 $this->_redirect('*/*/edit', array('id' => $model->getId()));
                 return;
             }
             $this->_redirect('*/*/');
             return;
         } catch (Exception $e) {
             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
             Mage::getSingleton('adminhtml/session')->setFormData($data);
             $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
             return;
         }
     }
     Mage::getSingleton('adminhtml/session')->addError(Mage::helper('eventmanager')->__('Unable to find the request to save'));
     $this->_redirect('*/*/');
 }
开发者ID:sshegde123,项目名称:wmp8,代码行数:34,代码来源:EventmanagercustomController.php


示例3: importMotorsDataAction

 public function importMotorsDataAction()
 {
     $helper = Mage::helper('M2ePro/Component_Ebay_Motors');
     $motorsType = $this->getRequest()->getPost('motors_type');
     if (!$motorsType || empty($_FILES['source']['tmp_name'])) {
         $this->getSession()->addError(Mage::helper('M2ePro')->__('Some of required fields are not filled up.'));
         return $this->_redirect('*/*/index');
     }
     $csvParser = new Varien_File_Csv();
     $tempCsvData = $csvParser->getData($_FILES['source']['tmp_name']);
     $csvData = array();
     $headers = array_shift($tempCsvData);
     foreach ($tempCsvData as $csvRow) {
         $csvData[] = array_combine($headers, $csvRow);
     }
     $added = 0;
     $existedItems = $this->getExistedMotorsItems();
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core/write');
     $tableName = $helper->getDictionaryTable($motorsType);
     foreach ($csvData as $csvRow) {
         if (!($insertsData = $this->getPreparedInsertData($csvRow, $existedItems))) {
             continue;
         }
         $added++;
         $connWrite->insert($tableName, $insertsData);
     }
     $this->_getSession()->addSuccess("Successfully added '{$added}' compatibility records.");
     return $this->_redirect('*/*/index');
 }
开发者ID:giuseppemorelli,项目名称:magento-extension,代码行数:29,代码来源:ConfigurationController.php


示例4: importDataAction

 public function importDataAction()
 {
     try {
         if ($this->getRequest()->getPost()) {
             if (isset($_FILES['import_file']['name']) && $_FILES['import_file']['name'] != '') {
                 $uploaderFile = new Varien_File_Uploader('import_file');
                 $uploaderFile->setAllowedExtensions(array('csv'));
                 $uploaderFile->setAllowRenameFiles(true);
                 $uploaderFile->setFilesDispersion(false);
                 $uploaderFilePath = Mage::getBaseDir('cache') . DS . 'mgs' . DS . 'brand' . DS . 'import' . DS . 'csv' . DS;
                 $uploaderFile->save($uploaderFilePath, $_FILES['import_file']['name']);
                 $filePath = $uploaderFilePath . $uploaderFile->getUploadedFileName();
                 $csv = new Varien_File_Csv();
                 $brands = $csv->getData($filePath);
                 $i = 0;
                 foreach ($brands as $brand) {
                     if ($i > 0) {
                         Mage::helper('brand')->import($brand);
                     }
                     $i++;
                 }
                 $urlRewriteCollection = Mage::getModel('core/url_rewrite')->getCollection()->addFieldToFilter('id_path', 'brand/index/');
                 foreach ($urlRewriteCollection as $url) {
                     $url->delete();
                 }
                 $urlRewrite = Mage::getModel('core/url_rewrite')->loadByIdPath('brand/index')->setIdPath('brand/index');
                 if (Mage::helper('brand')->urlKey() != '') {
                     $urlRewrite->setRequestPath(Mage::helper('brand')->urlKey());
                 } else {
                     $urlRewrite->setRequestPath('brand');
                 }
                 $urlRewrite->setTargetPath('brand/index/index');
                 $urlRewrite->setIsSystem(1);
                 $urlRewrite->save();
                 $collection = Mage::getModel('brand/brand')->getCollection();
                 foreach ($collection as $brand) {
                     $urlRewriteCollection = Mage::getModel('core/url_rewrite')->getCollection()->addFieldToFilter('id_path', 'brand/view/' . $brand->getId());
                     foreach ($urlRewriteCollection as $url) {
                         $url->delete();
                     }
                     $urlRewrite = Mage::getModel('core/url_rewrite')->loadByIdPath('brand/view/' . $brand->getId())->setIdPath('brand/view/' . $brand->getId());
                     if (Mage::helper('brand')->urlKey() != '') {
                         $urlRewrite->setRequestPath(Mage::helper('brand')->urlKey() . '/' . $brand->getUrlKey());
                     } else {
                         $urlRewrite->setRequestPath('brand/' . $brand->getUrlKey());
                     }
                     $urlRewrite->setTargetPath('brand/index/view/id/' . $brand->getId());
                     $urlRewrite->setIsSystem(1);
                     $urlRewrite->save();
                 }
                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('brand')->__('All brands were successfully imported.'));
                 $this->_redirect('*/*/index');
             }
         }
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
         $this->_redirect('*/*/import');
     }
 }
开发者ID:ramantalkin,项目名称:tmp01skin,代码行数:59,代码来源:BrandController.php


示例5: importproductAction

 public function importproductAction()
 {
     if (isset($_FILES['fileToUpload']['name']) && $_FILES['fileToUpload']['name'] != '') {
         try {
             $types = explode('.', $_FILES['fileToUpload']['name']);
             $fileType = $types[count($types) - 1];
             if ($fileType != 'csv') {
                 echo Mage::helper('inventoryplus')->__("Wrong file's format");
                 return;
             }
             $fileName = $_FILES['fileToUpload']['tmp_name'];
             $Object = new Varien_File_Csv();
             $dataFile = $Object->getData($fileName);
             $receiptstockProduct = array();
             $receiptstockProducts = array();
             $fields = array();
             $count = 0;
             $receiptstockHelper = Mage::helper('inventoryreceipt');
             $url = Mage::getUrl('inventoryreceiptadmin/adminhtml_receipt/index');
             if (count($dataFile)) {
                 foreach ($dataFile as $col => $row) {
                     if ($col == 0) {
                         if (count($row)) {
                             foreach ($row as $index => $cell) {
                                 $fields[$index] = (string) $cell;
                             }
                         }
                     } elseif ($col > 0) {
                         if (count($row)) {
                             foreach ($row as $index => $cell) {
                                 if (isset($fields[$index])) {
                                     $receiptstockProduct[$fields[$index]] = $cell;
                                 }
                             }
                         }
                         $receiptstockProducts[] = $receiptstockProduct;
                     }
                 }
             } else {
                 if (count($dataFile) == 0) {
                     echo Mage::helper('inventoryreceipt')->__("File is empty");
                     return;
                 }
             }
             if (count($receiptstockProducts) > 0) {
                 $receiptstockHelper->importProduct($receiptstockProducts);
             } else {
                 echo Mage::helper('inventoryreceipt')->__("Wrong information's structure");
                 return;
             }
         } catch (Exception $e) {
         }
     }
 }
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:54,代码来源:ReceiptController.php


示例6: getLanguageCsvData

 public function getLanguageCsvData()
 {
     $website = $this->getWebsite();
     $file = $website->getLanguageDirFile();
     try {
         $csv = new Varien_File_Csv();
         $data = $csv->getData($file);
         return $data;
     } catch (Exception $e) {
         return NULL;
     }
 }
开发者ID:Thinlt,项目名称:simicart,代码行数:12,代码来源:Localize.php


示例7: saveAction

 public function saveAction()
 {
     $data = $this->getRequest()->getParams();
     $uploader = new Mage_Core_Model_File_Uploader('file');
     $uploader->setAllowedExtensions(array('csv'));
     $uploader->setAllowRenameFiles(true);
     $path = Mage::getBaseDir('var') . DS . 'import';
     if (!file_exists($path)) {
         mkdir($path, 0777);
     }
     try {
         $result = $uploader->save($path);
         $fullPath = $result['path'] . DS . $result['file'];
         $csv = new Varien_File_Csv();
         $data = $csv->getData($fullPath);
         $items = array();
         if (count($data) > 1) {
             for ($i = 1; $i < count($data); $i++) {
                 $item = array();
                 for ($j = 0; $j < count($data[0]); $j++) {
                     if (isset($data[$i][$j]) && trim($data[$i][$j]) != '') {
                         $item[strtolower($data[0][$j])] = $data[$i][$j];
                     }
                 }
                 $items[] = $item;
             }
         }
         $resource = Mage::getSingleton('core/resource');
         $writeConnection = $resource->getConnection('core_write');
         $table = $resource->getTableName('seo/redirect');
         $table2 = $resource->getTableName('seo/redirect_store');
         $i = 0;
         foreach ($items as $item) {
             pr($item);
             if (!isset($item['url_from']) || !isset($item['url_to'])) {
                 continue;
             }
             $item = new Varien_Object($item);
             $query = "REPLACE {$table} SET\n                    url_from = '" . addslashes($item->getUrlFrom()) . "',\n                    url_to = '" . addslashes($item->getUrlTo()) . "',\n                    is_redirect_only_error_page = '" . addslashes($item->getIsRedirectOnlyErrorPage()) . "',\n                    comments = '" . addslashes($item->getComments()) . "',\n                    is_active = '" . addslashes($item->getIsActive()) . "';\n                    REPLACE {$table2} SET\n                        store_id = 0,\n                        redirect_id = LAST_INSERT_ID();\n                     ";
             $writeConnection->query($query);
             $i++;
         }
         Mage::getSingleton('adminhtml/session')->addSuccess('' . $i . ' records were inserted or updated');
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
     }
     $this->_redirect('*/*/');
 }
开发者ID:technomagegithub,项目名称:olgo.nl,代码行数:48,代码来源:RedirectimportController.php


示例8: _importStopwords

 protected function _importStopwords($file)
 {
     $csv = new Varien_File_Csv();
     $data = $csv->getData(Mage::getBaseDir('var') . DS . 'import' . DS . $file);
     $result = array();
     foreach ($data as $value) {
         $result[] = array('stopword' => $value[0]);
     }
     if (strlen(serialize($result)) < 65535) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig('searchsphinx/advanced/stopwords', serialize($result), 'default', 0);
     } else {
         return 'File too long';
     }
     return sprintf('Imported %s lines', count($result));
 }
开发者ID:vishalpatel14,项目名称:indiankalaniketan,代码行数:16,代码来源:search.php


示例9: saveAction

 public function saveAction()
 {
     $data = $this->getRequest()->getParams();
     $uploader = new Mage_Core_Model_File_Uploader('file');
     $uploader->setAllowedExtensions(array('csv'));
     $uploader->setAllowRenameFiles(true);
     $path = Mage::getBaseDir('var') . DS . 'import';
     if (!file_exists($path)) {
         mkdir($path, 0777);
     }
     try {
         $result = $uploader->save($path);
         $fullPath = $result['path'] . DS . $result['file'];
         $csv = new Varien_File_Csv();
         $data = $csv->getData($fullPath);
         $items = array();
         if (count($data) > 1) {
             for ($i = 1; $i < count($data); $i++) {
                 $item = array();
                 for ($j = 0; $j < count($data[0]); $j++) {
                     if (isset($data[$i][$j]) && trim($data[$i][$j]) != '') {
                         $item[strtolower($data[0][$j])] = $data[$i][$j];
                     }
                 }
                 $items[] = $item;
             }
         }
         $resource = Mage::getSingleton('core/resource');
         $writeConnection = $resource->getConnection('core_write');
         $table = $resource->getTableName('seoautolink/link');
         $table2 = $resource->getTableName('seoautolink/link_store');
         $i = 0;
         foreach ($items as $item) {
             if (!isset($item['keyword'])) {
                 continue;
             }
             $item = new Varien_Object($item);
             $query = "REPLACE {$table} SET\n                    keyword = '" . addslashes($item->getKeyword()) . "',\n                    url = '" . addslashes($item->getUrl()) . "',\n                    url_title = '" . addslashes($item->getUrlTitle()) . "',\n                    url_target = '" . addslashes($item->getUrlTarget()) . "',\n                    is_nofollow = '" . (int) $item->getIsNofollow() . "',\n                    max_replacements = '" . (int) $item->getMaxReplacements() . "',\n                    sort_order = '" . (int) $item->getSortOrder() . "',\n                    occurence = '" . (int) $item->getOccurence() . "',\n                    is_active = '" . (int) $item->getIsActive() . "',\n                    created_at = '" . now() . "',\n                    updated_at = '" . now() . "';\n                    REPLACE {$table2} SET\n                        store_id = '" . (int) $item->getStoreId() . "',\n                        link_id = LAST_INSERT_ID();\n                     ";
             $writeConnection->query($query);
             $i++;
         }
         Mage::getSingleton('adminhtml/session')->addSuccess('' . $i . ' records were inserted or updated');
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
     }
     $this->_redirect('*/*/');
 }
开发者ID:technomagegithub,项目名称:olgo.nl,代码行数:47,代码来源:ImportController.php


示例10: importFilesRelations

 public function importFilesRelations($csvPath, $uploadedFiles)
 {
     $csv = new Varien_File_Csv();
     $data = $csv->getData($csvPath);
     foreach ($data as $line) {
         if (!is_array($line) || count($line) != 2) {
             continue;
         }
         $files = explode(';', $line[1]);
         $fileIds = array();
         foreach ($files as $path) {
             $fileIds[] = array_search(Mage::getBaseDir('media') . '/downloads_import/' . $path, $uploadedFiles);
         }
         $skus = explode(';', $line[0]);
         $this->_assignFiles($fileIds, $skus);
     }
 }
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:17,代码来源:Import.php


示例11: getExtensions

 public function getExtensions()
 {
     $data = array();
     try {
         $file = 'http://dg8i44zfacfed.cloudfront.net/featured_product.csv';
         $content = $this->urlGetContents($file);
         $path = Mage::getBaseDir('media') . DS . 'import' . DS . 'featured_product.csv';
         if (!file_exists(Mage::getBaseDir('media') . DS . 'import')) {
             mkdir(Mage::getBaseDir('media') . DS . 'import');
         }
         file_put_contents($path, $content);
         $csv = new Varien_File_Csv();
         $data = $csv->getData($path);
         @unlink($path);
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return $data;
 }
开发者ID:xiaoguizhidao,项目名称:BumblebeeSite,代码行数:19,代码来源:Jsinit.php


示例12: getImportCsvAction

 public function getImportCsvAction()
 {
     if (isset($_FILES['fileToUpload']['name']) && $_FILES['fileToUpload']['name'] != '') {
         try {
             $fileName = $_FILES['fileToUpload']['tmp_name'];
             $Object = new Varien_File_Csv();
             $dataFile = $Object->getData($fileName);
             $warehouseProduct = array();
             $warehouseProducts = array();
             $fields = array();
             $count = 0;
             $helper = Mage::helper('inventorywarehouse/warehouse');
             if (count($dataFile)) {
                 foreach ($dataFile as $col => $row) {
                     if ($col == 0) {
                         if (count($row)) {
                             foreach ($row as $index => $cell) {
                                 $fields[$index] = (string) $cell;
                             }
                         }
                     } elseif ($col > 0) {
                         if (count($row)) {
                             foreach ($row as $index => $cell) {
                                 if (isset($fields[$index])) {
                                     $warehouseProduct[$fields[$index]] = $cell;
                                 }
                             }
                         }
                         $source = $this->getRequest()->getParam('source');
                         $productId = Mage::getModel('catalog/product')->getIdBySku($warehouseProduct['SKU']);
                         $warehouseproduct = Mage::getModel('inventoryplus/warehouse_product')->getCollection()->addFieldToFilter('warehouse_id', $source)->addFieldToFilter('product_id', $productId);
                         if (!$warehouseproduct->getSize()) {
                             $warehouseProducts[] = $warehouseProduct;
                         }
                     }
                 }
             }
             $helper->importProduct($warehouseProducts);
         } catch (Exception $e) {
         }
     }
 }
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:42,代码来源:WarehouseController.php


示例13: exportTableratesAction

 /**
  * Export the eParcel table rates as a CSV file.
  */
 public function exportTableratesAction()
 {
     $rates = Mage::getResourceModel('australia/shipping_carrier_eparcel_collection');
     $response = array(array('Country', 'Region/State', 'Postcodes', 'Weight from', 'Weight to', 'Parcel Cost', 'Cost Per Kg', 'Delivery Type', 'Charge Code Individual', 'Charge Code Business'));
     foreach ($rates as $rate) {
         $countryId = $rate->getData('dest_country_id');
         $countryCode = Mage::getModel('directory/country')->load($countryId)->getIso3Code();
         $regionId = $rate->getData('dest_region_id');
         $regionCode = Mage::getModel('directory/region')->load($regionId)->getCode();
         $response[] = array($countryCode, $regionCode, $rate->getData('dest_zip'), $rate->getData('condition_from_value'), $rate->getData('condition_to_value'), $rate->getData('price'), $rate->getData('price_per_kg'), $rate->getData('delivery_type'), $rate->getData('charge_code_individual'), $rate->getData('charge_code_business'));
     }
     $csv = new Varien_File_Csv();
     $temp = tmpfile();
     foreach ($response as $responseRow) {
         $csv->fputcsv($temp, $responseRow);
     }
     rewind($temp);
     $contents = stream_get_contents($temp);
     $this->_prepareDownloadResponse('tablerates.csv', $contents);
     fclose($temp);
 }
开发者ID:bincani,项目名称:fontis_australia,代码行数:24,代码来源:EparcelController.php


示例14: saveAction

 public function saveAction()
 {
     if (!isset($_FILES['csv_store'])) {
         Mage::getSingleton('core/session')->addError('Not selected file!');
         $this->_redirect('*/*/importstore');
         return;
     }
     $oFile = new Varien_File_Csv();
     $data = $oFile->getData($_FILES['csv_store']['tmp_name']);
     $store = Mage::getModel('storepickup/store');
     $storeData = array();
     try {
         $total = 0;
         foreach ($data as $col => $row) {
             if ($col == 0) {
                 $index_row = $row;
             } else {
                 for ($i = 0; $i < count($row); $i++) {
                     $storeData[$index_row[$i]] = $row[$i];
                 }
                 $store->setData($storeData);
                 $store->setId(null);
                 if ($store->import()) {
                     $total++;
                 }
             }
         }
         $this->_redirect('*/adminhtml_store/index');
         if ($total != 0) {
             Mage::getSingleton('core/session')->addSuccess('Imported successful total ' . $total . ' stores');
         } else {
             Mage::getSingleton('core/session')->addSuccess('Stores exist');
         }
     } catch (Exception $e) {
         Mage::getSingleton('core/session')->addError($e->getMessage());
         $this->_redirect('*/*/importstore');
     }
 }
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:38,代码来源:ImportController.php


示例15: getPendingList

 public function getPendingList()
 {
     $csv = new Varien_File_Csv();
     $pendingList = array();
     try {
         $todoList = $csv->getData($this->_helper->getStoragePath() . $this->_helper->getAllActionsFilename());
         $doneList = $csv->getData($this->_helper->getStoragePath() . $this->_helper->getExecutedActionsFilename());
         $todo = array();
         $done = array();
         foreach ($todoList as $k => $v) {
             $todo[$k] = implode('|', $v);
         }
         foreach ($doneList as $k => $v) {
             $done[$k] = implode('|', $v);
         }
         foreach (array_diff($todo, $done) as $k => $v) {
             $pendingList[$k] = $todoList[$k];
         }
     } catch (Exception $e) {
         $this->_helper->log($e->getMessage());
     }
     return $pendingList;
 }
开发者ID:ngreimel,项目名称:mageploy,代码行数:23,代码来源:File.php


示例16: import

 public function import()
 {
     $file = $this->_path . $this->_fileName;
     if (!is_file($file)) {
         Mage::throwException(Mage::helper('ism_newstore_members')->__('Invalid file!'));
     }
     $csv = new Varien_File_Csv();
     $data = $csv->getData($file);
     unset($data[0]);
     $skuCodes = array_column($data, 0);
     $prices = array_column($data, 1);
     $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('sku', array('in' => $skuCodes));
     $prices = array_combine($skuCodes, $prices);
     foreach ($collection as $item) {
         try {
             $item->setIsmNewstoremembersPrice($prices[$item->getSku()])->save();
         } catch (Exception $e) {
             Mage::log('Error with product: ' . $item->getSku());
         }
     }
     unlink($file);
     return $this;
 }
开发者ID:swnsma,项目名称:practice,代码行数:23,代码来源:Import.php


示例17: indexAction

 public function indexAction()
 {
     $file = "https://cart.simicommerce.com/media/simicart/languages/0/e/e089b299ff3a892ebe25e02725c4b33a.csv";
     $file = Mage::getBaseDir('media') . DS . 'simicart' . DS . 'languages' . DS . "2/5/53de68fd512d1216dd74ae964b99d7e8.csv";
     $csv = new Varien_File_Csv();
     $data = $csv->getData($file);
     $codes = $data[0];
     //print_r($data);die();
     for ($i = 1; $i < count($data); $i++) {
         for ($j = 1; $j < count($data[$i]); $j++) {
             if ($codes[$j]) {
                 //ton tai code
                 if (strpos($data[$i][0], '/*') === false) {
                     // ko phai comment
                     if ($data[$i][$j]) {
                         // cum tu translated co ton tai
                         $str .= '"' . $data[$i][0] . '" = "' . $data[$i][$j] . '";' . "<br>";
                     }
                 }
             }
         }
     }
     echo $str;
 }
开发者ID:Thinlt,项目名称:simicart,代码行数:24,代码来源:TestController.php


示例18: _importData

 protected function _importData()
 {
     $reviewsFile = $this->getArg('reviews');
     $ratingsFile = $this->getArg('ratings');
     $mapping = $this->getArg('mapping');
     $baseDir = Mage::getBaseDir();
     $reviewPath = $baseDir . '/' . $reviewsFile;
     $ratingPath = $baseDir . '/' . $ratingsFile;
     if ($mapping) {
         $mapping = $this->_parseMapping($mapping);
     }
     if (file_exists($reviewPath) && file_exists($ratingPath)) {
         $csv = new Varien_File_Csv();
         $reviews = $this->_getCsvWithHeaders($csv->getData($reviewPath));
         $ratings = $this->_getCsvWithHeaders($csv->getData($ratingPath));
         $count = 0;
         foreach ($reviews as $review) {
             $reviewModel = Mage::getModel('review/review');
             $reviewModel->setData(array('entity_id' => $reviewModel->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE), 'entity_pk_value' => $mapping ? $mapping[$review['entity_pk_value']] : $review['entity_pk_value'], 'status_id' => $review['status_id'], 'customer_id' => null, 'title' => $review['title'], 'nickname' => $review['nickname'], 'detail' => $review['detail'], 'store_id' => $review['store_id'], 'stores' => array($review['store_id'])))->save();
             //double save because review model checks for an id and resets this on new objects - i know it sucks
             $reviewModel->setCreatedAt($review['created_at'])->save();
             $reviewRatings = array_filter($ratings, function ($rating) use($review) {
                 return $rating['review_id'] == $review['review_id'];
             });
             foreach ($reviewRatings as $rating) {
                 Mage::getModel('rating/rating')->setRatingId($rating['rating_id'])->setReviewId($reviewModel->getId())->setCustomerId($rating['customer_id'])->addOptionVote($rating['option_id'], $mapping ? $mapping[$rating['entity_pk_value']] : $rating['entity_pk_value']);
             }
             $reviewModel->aggregate();
             $count++;
         }
         echo 'Successfully imported ' . $count . ' reviews';
     } else {
         echo "One of the files doesn't exist.";
     }
     return $this;
 }
开发者ID:adamjreed,项目名称:legacyreviews,代码行数:36,代码来源:legacy-reviews.php


示例19: importAction

 public function importAction()
 {
     $fileTrue = $this->fileImportCsvUpload();
     if ($fileTrue) {
         $file = 'var/CodImport/' . $fileTrue;
         $csv = new Varien_File_Csv();
         $data = $csv->getData($file);
         if (count($data[0] == 2) && $data[0][0] == 'Country' && $data[0][1] == 'Zip/Postal Code') {
             //echo "<pre>"; print_r($data);die;
             //Mage::getResourceModel('cod/postcode')->truncate();
             $coll = Mage::getModel('cod/postcode')->getCollection();
             $tableName = $coll->getResource()->getMainTable();
             $conn = $coll->getConnection();
             $conn->truncateTable($tableName);
             $i = 1;
             foreach ($data as $value) {
                 if ($i != 1) {
                     $datacsv = array('website_id' => 1, 'dest_country_id' => $value[0], 'dest_zip' => $value[1]);
                     $model = Mage::getModel('cod/postcode')->setData($datacsv);
                     try {
                         $insertId = $model->save()->getId();
                     } catch (Exception $e) {
                         echo $e->getMessage();
                     }
                 }
                 $i++;
             }
             Mage::getSingleton('core/session')->addSuccess("Import success");
         } else {
             Mage::getSingleton('core/session')->addError("Import is failed.");
         }
     } else {
         Mage::getSingleton('core/session')->addError("Import is failed.");
     }
     $this->_redirect("*/*/index");
 }
开发者ID:vishalpatel14,项目名称:indiankalaniketan,代码行数:36,代码来源:CodimportexportController.php


示例20: typeFormSurvery

 /**
  * @function save type Form csv data
  * 
  * 
  * 
  * 
  * */
 public function typeFormSurvery()
 {
     try {
         $path = Mage::getBaseDir() . DS . 'survey_csv';
         if (!is_dir()) {
             mkdir($path);
         }
         $uploader = new Varien_File_Uploader('csv_file');
         $uploader->setAllowedExtensions(array('csv'));
         $uploader->setAllowCreateFolders(true);
         $uploader->setAllowRenameFiles(true);
         $uploader->setFilesDispersion(false);
         $savedPath = $uploader->save($path, $fname);
         $savedFilePath = $savedPath['path'] . DS . $savedPath['file'];
         $csv = new Varien_File_Csv();
         $data = $csv->getData($savedFilePath);
         unlink($savedFilePath);
         $surveryModel = Mage::getModel('survey/survey');
         $hasColumnNameRow = $surveryModel->getCollection()->setPageSize(1);
         //zend_debug::dump($data);exit;
         if (count($hasColumnNameRow) == 0) {
             //$surveryModel->setData('completed', strtotime(trim($value[1])));
             //$surveryModel->setData('token', trim($value[4]));
             $surveryModel->setData('q1', $data[0][1]);
             $surveryModel->setData('q2', $data[0][3]);
             // $surveryModel->setData('q3', $data[0][11]);
             $surveryModel->setData('q4', $data[0][2]);
             $surveryModel->setData('q5', $data[0][5]);
             $surveryModel->setData('q6', $data[0][4]);
             $surveryModel->setData('q7', $data[0][7]);
             $surveryModel->setData('q8', $data[0][6]);
             //$surveryModel->setData('q9', $data[0][17]);
             $surveryModel->save();
             $surveryModel->unsetData();
         }
         unset($data[0]);
         foreach ($data as $key => $value) {
             $surveryModel->setData('token', $value[9]);
             $date = trim($value[12]);
             $date = str_replace('/', '-', $date);
             $surveryModel->setData('completed', date('Y-m-d', strtotime($date)));
             $surveryModel->setData('q1', $value[1]);
             $surveryModel->setData('q2', $value[3]);
             //$surveryModel->setData('q3', $value[11]);
             $surveryModel->setData('q4', $value[2]);
             $surveryModel->setData('q5', $value[5]);
             $surveryModel->setData('q6', $value[4]);
             $surveryModel->setData('q7', $value[7]);
             $surveryModel->setData('q8', $value[6]);
             //$surveryModel->setData('q9', $value[17]);
             $surveryModel->save();
             $surveryModel->unsetData();
         }
         Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Survey  Uploaded Successfully.. '));
         Mage::getSingleton('adminhtml/session')->setCrmData(false);
         $this->_redirect('*/*/');
         return;
     } catch (exception $e) {
         Mage::getSingleton('adminhtml/session')->addError('There is some error.. ');
         Mage::getSingleton('adminhtml/session')->setCrmData($this->getRequest()->getPost());
         $this->_redirect('*/*/');
         return;
     }
 }
开发者ID:platonicsolution,项目名称:local-server,代码行数:71,代码来源:-SurveyController.php



注:本文中的Varien_File_Csv类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Varien_File_Uploader类代码示例发布时间:2022-05-23
下一篇:
PHP Varien_Event_Observer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap