/** * Rotate all files in var/log which ends with .log */ public function rotateLogs() { $var = Mage::getBaseDir('log'); $logDir = new Varien_Io_File(); $logDir->cd($var); $logFiles = $logDir->ls(Varien_Io_File::GREP_FILES); foreach ($logFiles as $logFile) { if ($logFile['filetype'] == 'log') { $filename = $logFile['text']; if (extension_loaded('zlib')) { $zipname = $var . DS . $this->getArchiveName($filename); $zip = gzopen($zipname, 'wb9'); gzwrite($zip, $logDir->read($filename)); gzclose($zip); } else { $logDir->cp($filename, $this->getArchiveName($filename)); } foreach ($this->getFilesOlderThan(self::MAX_FILE_DAYS, $var, $filename) as $oldFile) { $logDir->rm($oldFile['text']); } $logDir->rm($filename); } } $logDir->close(); }
/** * Export function: * - Returns false, if an error occured or if there are no orders to export * - Returns array, containing the filename and the file contents * * @return bool|array */ public function export() { $collection = $this->_hasOrdersToExport(); if (!$collection) { return false; } $fileName = $this->getFileName(); // Open file $file = new Varien_Io_File(); $file->open(array('path' => Mage::getBaseDir('var'))); $file->streamOpen($fileName); // Add headline $row = array('Kundenname', 'BLZ', 'Kontonummer', 'BIC/Swift-Code', 'IBAN', 'Betrag', 'Verwendungszweck'); $file->streamWriteCsv($row); // Add rows foreach ($collection as $order) { /* @var $orderModel Mage_Sales_Model_Order */ $orderModel = Mage::getModel('sales/order')->load($order->getData('entity_id')); /* @var $paymentMethod Itabs_Debit_Model_Debit */ $paymentMethod = $orderModel->getPayment()->getMethodInstance(); // Format order amount $amount = number_format($order->getData('grand_total'), 2, ',', '.'); $row = array('name' => $paymentMethod->getAccountName(), 'bank_code' => $paymentMethod->getAccountBLZ(), 'account_number' => $paymentMethod->getAccountNumber(), 'account_swift' => $paymentMethod->getAccountSwift(), 'account_iban' => $paymentMethod->getAccountIban(), 'amount' => $amount . ' ' . $order->getData('order_currency_code'), 'purpose' => 'Bestellung Nr. ' . $order->getData('increment_id')); $file->streamWriteCsv($row); $this->_getDebitHelper()->setStatusAsExported($order->getId()); } // Close file, get file contents and delete temporary file $file->close(); $filePath = Mage::getBaseDir('var') . DS . $fileName; $fileContents = file_get_contents($filePath); $file->rm($fileName); $response = array('file_name' => $fileName, 'file_content' => $fileContents); return $response; }
protected function finaliseStoreData() { // Write DOM to file $filename = $this->info("clean_store_name") . '-products.xml'; $io = new Varien_Io_File(); $io->setAllowCreateFolders(true); $io->open(array('path' => $this->getPath())); $io->write($filename, $this->_dom->saveXML()); $io->close(); }
/** * @param $path * @return bool */ private function checkFolderExists($path) { try { $io_proxy = new Varien_Io_File(); $io_proxy->setAllowCreateFolders(true); $io_proxy->open(array($path)); $io_proxy->close(); unset($io_proxy); return true; } catch (Exception $e) { return false; } }
protected function _rewriteGrid($blcgClass, $originalClass, $gridType) { $classParts = explode('_', str_replace($this->_getBlcgClassPrefix(), '', $blcgClass)); $fileName = array_pop($classParts) . '.php'; $rewriteDir = dirname(__FILE__) . '/../../../Block/Rewrite/' . implode('/', $classParts); $ioFile = new Varien_Io_File(); $ioFile->setAllowCreateFolders(true); $ioFile->checkAndCreateFolder($rewriteDir); $ioFile->cd($rewriteDir); // Use open() to initialize Varien_Io_File::$_iwd // Prevents a warning when chdir() is used without error control in Varien_Io_File::read() if ($ioFile->fileExists($fileName, true) && $ioFile->open()) { if ($content = $ioFile->read($fileName)) { $lines = preg_split('#\\R#', $content, 3); $isUpToDate = false; if (isset($lines[0]) && isset($lines[1]) && $lines[0] == '<?php' && preg_match('#^// BLCG_REWRITE_CODE_VERSION\\=([0-9]+)$#', $lines[1], $matches)) { if ($matches[1] === strval(self::REWRITE_CODE_VERSION)) { $isUpToDate = true; } } } $ioFile->close(); if ($isUpToDate) { return $this; } } $content = '<?php // BLCG_REWRITE_CODE_VERSION=' . self::REWRITE_CODE_VERSION . ' // This file was generated automatically. Do not alter its content. /** * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * * @category BL * @package BL_CustomGrid * @copyright Copyright (c) ' . date('Y') . ' Benoît Leulliette <*****@*****.**> * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ '; $content .= $this->_getRewriteCode($blcgClass, $originalClass, $gridType); if (!$ioFile->write($fileName, $content)) { Mage::throwException(); } return $this; }
private function _generateCss($store) { $io = new Varien_Io_File(); $path = Mage::getBaseDir("skin") . DS . 'frontend' . DS . 'base' . DS . 'default' . DS . 'css' . DS . 'weltpixel' . DS; $name = 'color_' . $store->getCode() . '.css'; $file = $path . DS . $name; $io->setAllowCreateFolders(true); $io->open(array('path' => $path)); $io->streamOpen($file, 'w+'); $io->streamLock(true); $cssContent = Mage::helper('selector')->getDynamicCssContent($store->getId()); $io->streamWrite($cssContent); $io->close(); }
protected function _getRuleClasses() { $classes = array(); $rulesDir = Mage::getModuleDir('', 'Mirasvit_Email') . DS . 'Model' . DS . 'Rule' . DS . 'Condition'; $io = new Varien_Io_File(); $io->open(); $io->cd($rulesDir); foreach ($io->ls(Varien_Io_File::GREP_FILES) as $event) { if ($event['filetype'] != 'php') { continue; } $info = pathinfo($event['text']); $class = strtolower($info['filename']); $classes[$class] = 'email/rule_condition_' . strtolower($class); } $io->close(); return $classes; }
public function getVariablesHelpers() { $result = array(); $pathes = array('email' => Mage::getModuleDir('', 'Mirasvit_Email') . DS . 'Helper' . DS . 'Variables', 'emaildesign' => Mage::getModuleDir('', 'Mirasvit_EmailDesign') . DS . 'Helper' . DS . 'Variables'); $io = new Varien_Io_File(); $io->open(); foreach ($pathes as $pathKey => $path) { $io->cd($path); foreach ($io->ls(Varien_Io_File::GREP_FILES) as $event) { if ($event['filetype'] != 'php') { continue; } $info = pathinfo($event['text']); $result[] = $pathKey . '/variables_' . strtolower($info['filename']); } } $io->close(); return $result; }
protected function finaliseStoreData() { // Write CSV data to temp file $memoryLimit = 16 * 1024 * 1024; $fp = fopen("php://temp/maxmemory:{$memoryLimit}", 'r+'); foreach ($this->_rows as $row) { fputcsv($fp, $row, $this->_separator); } rewind($fp); // Write temp file data to file $cleanStoreName = str_replace('+', '-', strtolower(urlencode($this->_store->getName()))); $filename = $cleanStoreName . '-products.csv'; $io = new Varien_Io_File(); $io->setAllowCreateFolders(true); $io->open(array('path' => $this->getPath())); $io->write($filename, $fp); $io->close(); fclose($fp); }
protected function createConfigFile() { $base_url = explode("/", Mage::getBaseUrl('js')); $base_url = explode($base_url[count($base_url) - 2], Mage::getBaseUrl('js')); $this->_base_url = $base_url[0]; $base_URLs = preg_replace('/http:\\/\\//is', 'https://', $base_url[0]); /** Create file config for javascript */ $js = "var mw_baseUrl = '{BASE_URL}';\n"; $js = str_replace("{BASE_URL}", $base_url[0], $js); $js .= "var mw_baseUrls = '{$base_URLs}';\n"; $js .= "var FACEBOOK_ID = '" . Mage::helper('mw_socialgift')->getFBID() . "';\n"; $file = new Varien_Io_File(); $file->checkAndCreateFolder($this->baseDir . "/media/mw_socialgift/js/"); $file->checkAndCreateFolder($this->baseDir . "/media/mw_socialgift/css/"); foreach ($this->_multi_path_js as $code => $path) { if (!file_exists($path) && Mage::app()->getStore()->getCode() == $code) { $file->write($path, $js); $file->close(); } } return $js; }
public function getContentCustomCss() { $output = ""; $theme = Mage::registry('theme_data')->get('group'); $tmp_theme = explode("/", $theme); if (count($tmp_theme) == 1) { $theme = "default/" . $tmp_theme; } if ($theme) { $custom_css_path = Mage::getBaseDir('skin') . "/frontend/" . $theme . "/css/local/custom.css"; if (is_file($custom_css_path) && file_exists($custom_css_path)) { $file = new Varien_Io_File(); $file->open(array('path' => Mage::getBaseDir('skin') . "/frontend/" . $theme . "/css/local/")); //$flocal->streamOpen('customers.txt', 'r'); $output = $file->read(Mage::getBaseDir('skin') . "/frontend/" . $theme . "/css/local/custom.css"); $file->close(); } } return $output; }
public static function update() { Mage::log('Fontis/Australia_Model_MyShopping_Cron: Entered update function'); if (Mage::getStoreConfig('fontis_feeds/myshoppingfeed/active')) { $io = new Varien_Io_File(); $io->setAllowCreateFolders(true); $io->open(array('path' => self::getPath())); // Loop through all stores: foreach (Mage::app()->getStores() as $store) { Mage::log('Fontis/Australia_Model_MyShopping_Cron: Processing store: ' . $store->getName()); $clean_store_name = str_replace('+', '-', strtolower(urlencode($store->getName()))); Fontis_Australia_Model_MyShopping_Cron::$debugCount = 0; // Write the entire products xml file: Mage::log('Fontis/Australia_Model_MyShopping_Cron: Generating All Products XML File'); $products_result = self::getProductsXml($store); $filename = $clean_store_name . '-products.xml'; $io->write($filename, $products_result['xml']); Mage::log('Fontis/Australia_Model_MyShopping_Cron: Wrote ' . Fontis_Australia_Model_MyShopping_Cron::$debugCount . " records to " . self::getPath() . $filename); } $io->close(); } else { Mage::log('Fontis/Australia_Model_MyShopping_Cron: Disabled'); } }
public function getThemeCustomizePath($theme = "") { $tmp_theme = explode("/", $theme); if (count($tmp_theme) == 1) { $theme = "default/" . $theme; } $customize_path = Mage::getBaseDir('skin') . "/frontend/" . $theme . "/css/customize/"; if (!file_exists($customize_path)) { $file = new Varien_Io_File(); $file->mkdir($customize_path); $file->close(); } return $customize_path; }
/** * * especially developed for copying when we get incoming data as an image collection * instead of plain post... * */ public function beforeSave($object) { $storeId = $object->getStoreId(); $attributeId = $this->getAttribute()->getId(); $entityId = $object->getId(); $entityIdField = $this->getEntityIdField(); $entityTypeId = $this->getAttribute()->getEntity()->getTypeId(); $connection = $this->getConnection('write'); $values = $object->getData($this->getAttribute()->getName()); if (!is_array($values) && is_object($values)) { foreach ((array) $values->getItems() as $image) { // TOFIX $io = new Varien_Io_File(); $value = $image->getData(); $data = array(); $data[$entityIdField] = $entityId; $data['attribute_id'] = $attributeId; $data['position'] = $value['position']; $data['entity_type_id'] = $entityTypeId; $data['store_id'] = $storeId; if ($entityId) { $connection->insert($this->getTable(), $data); $lastInsertId = $connection->lastInsertId(); } else { continue; } unset($newFileName); $types = $this->getImageTypes(); foreach ($types as $type) { try { $io->open(); $path = Mage::getStoreConfig('system/filesystem/upload', 0); $io->cp($path . '/' . $type . '/' . 'image_' . $entityId . '_' . $value['value_id'] . '.' . 'jpg', $path . '/' . $type . '/' . 'image_' . $entityId . '_' . $lastInsertId . '.' . 'jpg'); $io->close(); } catch (Exception $e) { continue; } $newFileName = 'image_' . $entityId . '_' . $lastInsertId . '.' . 'jpg'; } $condition = array($connection->quoteInto('value_id = ?', $lastInsertId)); if (isset($newFileName)) { $data = array(); $data['value'] = $newFileName; $connection->update($this->getTable(), $data, $condition); } else { $connection->delete($this->getTable(), $condition); } } $object->setData($this->getAttribute()->getName(), array()); } return parent::beforeSave($object); }
public function saveAction() { $action = ""; if ($data = $this->getRequest()->getPost()) { $action = $this->getRequest()->getParam('action'); $themecontrol = isset($data['themecontrol']) ? $data['themecontrol'] : ''; $internal_modules = isset($data['module']) ? $data['module'] : array(); if (isset($_FILES['bg_image']['name']) && $_FILES['bg_image']['name'] != '') { try { /* Starting upload */ $uploader = new Varien_File_Uploader('bg_image'); // Any extention would work $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')); $uploader->setAllowRenameFiles(false); // Set the file upload mode // false -> get the file directly in the specified folder // true -> get the file in the product like folders // (file.jpg will go in something like /media/f/i/file.jpg) $uploader->setFilesDispersion(false); // We set media as the upload dir $path = Mage::getBaseDir('media') . '/ves_tempcp/upload/'; $uploader->save($path, $_FILES['bg_image']['name']); } catch (Exception $e) { } //this way the name is saved in DB $themecontrol['bg_image'] = 'ves_tempcp/upload/' . $_FILES['bg_image']['name']; } elseif (isset($themecontrol['bg_image']) && strpos($themecontrol['bg_image'], "ves_tempcp/upload/") === false) { $themecontrol['bg_image'] = "ves_tempcp/upload/" . $themecontrol['bg_image']; } elseif (isset($data['delete_bg_image']) && $data['delete_bg_image']) { if (file_exists(Mage::getBaseDir('media') . "/" . $themecontrol['bg_image'])) { @unlink(Mage::getBaseDir('media') . "/" . $themecontrol['bg_image']); } $themecontrol['bg_image'] = ""; } if (isset($themecontrol['custom_logo']) && strpos($themecontrol['custom_logo'], "images/") === false) { $themecontrol['custom_logo'] = "images/" . $themecontrol['custom_logo']; } elseif (isset($data['delete_custom_logo']) && $data['delete_custom_logo']) { if (file_exists(Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/images/" . $themecontrol['custom_logo'])) { @unlink(Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/images/" . $themecontrol['custom_logo']); } $themecontrol['custom_logo'] = ""; } if (isset($themecontrol['custom_logo_small']) && strpos($themecontrol['custom_logo_small'], "images/") === false) { $themecontrol['custom_logo_small'] = "images/" . $themecontrol['custom_logo_small']; } elseif (isset($data['delete_custom_logo_small']) && $data['delete_custom_logo_small']) { if (file_exists(Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/images/" . $themecontrol['custom_logo_small'])) { @unlink(Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/images/" . $themecontrol['custom_logo_small']); } $themecontrol['custom_logo_small'] = ""; } $data = array(); $custom_css = ""; if (isset($themecontrol['custom_css'])) { $custom_css = trim($themecontrol['custom_css']); unset($themecontrol['custom_css']); } $theme_id = $this->getRequest()->getParam('id'); $data['params'] = base64_encode(serialize($themecontrol)); $data['group'] = isset($themecontrol['default_theme']) ? $themecontrol['default_theme'] : 'ves default theme'; $data['is_default'] = 1; $data['stores'] = $this->getRequest()->getParam('stores'); $_model = Mage::getModel('ves_tempcp/theme')->load($theme_id); /* if(empty($data['theme_id']) && $_model->checkExistsByGroup($data['group'])){ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ves_tempcp')->__('The Theme is exist, you can not create a same theme!')); */ // $this->_redirect('*/*/'); /* return; }*/ $_model->setData($data); if ($theme_id) { $_model->setId($theme_id); } try { $_model->save(); /*Save custom css*/ if (!empty($custom_css)) { $theme_group = $_model->getGroup(); $tmp_theme = explode("/", $theme_group); if (count($tmp_theme) == 1) { $theme_group = "default/" . $theme_group; } $custom_css_path = Mage::getBaseDir('skin') . "/frontend/" . $theme_group . "/css/local/"; if (!file_exists($custom_css_path)) { $file = new Varien_Io_File(); $file->mkdir($custom_css_path); $file->close(); } Mage::helper("ves_tempcp")->writeToCache($custom_css_path, "custom", $custom_css); } /*End save custom css*/ /*Save internal modules*/ $theme_id = $_model->getId(); Mage::getModel('ves_tempcp/module')->cleanModules($theme_id); if (!empty($internal_modules)) { foreach ($internal_modules as $position => $modules) { if ($modules) { foreach ($modules as $key => $module) { $_module_model = Mage::getModel('ves_tempcp/module'); $_data = array(); $_data['theme_id'] = $theme_id; $_data['module_name'] = trim($key); $_data['module_title'] = trim($module['module_title']); $_data['module_data'] = $module['module_data']; $_data['block_id'] = $module['block_id']; $_data['layout'] = implode(",", $module['layout']); $_data['status'] = $module['status']; $_data['sort_order'] = $module['sort_order']; $_data['position'] = isset($module['position']) ? trim($module['position']) : trim($position); $_module_model->setData($_data); if ($module_id = $_module_model->getModuleId($key)) { $_module_model->setId($module_id); } try { $_module_model->save(); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); Mage::getSingleton('adminhtml/session')->setFormData($_data); } } } } } /*End Save internal modules*/ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ves_tempcp')->__('Theme was successfully saved')); Mage::getSingleton('adminhtml/session')->setFormData(false); if ($this->getRequest()->getParam('back')) { return; } if ($action == "save_stay") { $this->_redirect('*/*/edit', array('id' => $theme_id)); } else { $this->_redirect('*/*/'); } return; } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); Mage::getSingleton('adminhtml/session')->setFormData($data); return; } } Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ves_tempcp')->__('Unable to find theme to save')); $this->_redirect('*/*/'); }
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])); } } $import->invalidateIndex(); $session->addSuccess($this->__('Import successfully done.'), true); $this->_redirect('*/*/import'); } else { $session->addError($this->__('File is valid, but import is not possible'), false); } } $session->addNotice($import->getNotices()); $session->addNotice($this->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', $import->getProcessedRowsCount(), $import->getProcessedEntitiesCount(), $import->getInvalidRowsCount(), $import->getErrorsCount())); } } catch (Exception $e) { $session->addNotice($this->__('Please fix errors and re-upload file'))->addError($e->getMessage()); } } elseif ($this->getRequest()->isPost() && empty($_FILES)) { $session->addError($this->__('File was not uploaded')); } else { $session->addError($this->__('Data is invalid or file is not uploaded')); } $this->_redirect('*/*/import'); }
public static function update() { Mage::log('Fontis/Australia_Model_Getprice_Cron: Entered update function'); if (Mage::getStoreConfig('fontis_feeds/getpricefeed/active')) { $io = new Varien_Io_File(); $io->setAllowCreateFolders(true); $io->open(array('path' => self::getPath())); // Loop through all stores: foreach (Mage::app()->getStores() as $store) { Mage::log('Fontis/Australia_Model_Getprice_Cron: Processing store: ' . $store->getName()); $clean_store_name = str_replace('+', '-', strtolower(urlencode($store->getName()))); // Write the entire products xml file: Mage::log('Fontis/Australia_Model_Getprice_Cron: Generating All Products XML File'); $products_result = self::getProductsXml($store); $io->write($clean_store_name . '-products.xml', $products_result['xml']); Mage::log('Fontis/Australia_Model_Getprice_Cron: Wrote to file: ' . $clean_store_name . '-products.xml', $products_result['xml']); // Write the leaf categories xml file: Mage::log('Fontis/Australia_Model_Getprice_Cron: Generating Categories XML File'); $categories_result = self::getCategoriesXml($store); $io->write($clean_store_name . '-categories.xml', $categories_result['xml']); Mage::log('Fontis/Australia_Model_Getprice_Cron: Wrote to file: ' . $clean_store_name . '-categories.xml', $categories_result['xml']); // Write for each leaf category, their products xml file: foreach ($categories_result['link_ids'] as $link_id) { Mage::log('Fontis/Australia_Model_Getprice_Cron: Generating Product Category XML File: ' . $link_id); $subcategory_products_result = self::getProductsXml($store, $link_id); $io->write($clean_store_name . '-products-' . $link_id . '.xml', $subcategory_products_result['xml']); Mage::log('Fontis/Australia_Model_Getprice_Cron: Wrote to file: ' . $clean_store_name . '-products-' . $link_id . '.xml', $subcategory_products_result['xml']); } } $io->close(); } else { Mage::log('Fontis/Australia_Model_Getprice_Cron: Disabled'); } }
/** * Cache the widget images. * * @param string $type type * @param string $tsId Trusted Rating Id * * @return void */ private function _cacheImageData($type, $tsId = null) { $ioObject = new Varien_Io_File(); $ioObject->open(); if ($type == 'emailWidget') { $emailWidgetName = $this->getRatingLinkData('emailratingimage'); $readPath = self::EMAIL_WIDGET_LINK . $emailWidgetName; $writePath = self::IMAGE_LOCAL_PATH . $emailWidgetName; $cacheId = self::EMAIL_CACHEID; } else { $readPath = self::WIDGET_LINK . $tsId . self::WIDGET_FILE_SUFFIX; $writePath = self::IMAGE_LOCAL_PATH . $tsId . self::WIDGET_FILE_SUFFIX; $cacheId = self::CACHEID; } $result = $ioObject->read($readPath); $ioObject->write($writePath, $result); Mage::app()->saveCache($writePath, $cacheId, array(), 1); $ioObject->close(); }
protected function finaliseStoreData() { // Write the end of the xml document $this->doc->endElement(); $this->doc->endDocument(); // Write dom to file $cleanStoreName = str_replace('+', '-', strtolower(urlencode($this->_store->getName()))); $filename = $cleanStoreName . '-products.xml'; $io = new Varien_Io_File(); $io->setAllowCreateFolders(true); $io->open(array('path' => $this->getPath())); $io->write($filename, $this->doc->outputMemory()); $io->close(); }