Example #1
0
 protected function _replaceFilenameVariables($filename, $exportArray)
 {
     $filename = str_replace("|", "-", $filename);
     // Remove the pipe character - it's not allowed in file names anyways and we use it to separate multiple files in the DB
     // Replace variables in filename
     $replaceableVariables = array('/%d%/' => Mage::getSingleton('core/date')->date('d'), '/%m%/' => Mage::getSingleton('core/date')->date('m'), '/%y%/' => Mage::getSingleton('core/date')->date('y'), '/%Y%/' => Mage::getSingleton('core/date')->date('Y'), '/%h%/' => Mage::getSingleton('core/date')->date('H'), '/%i%/' => Mage::getSingleton('core/date')->date('i'), '/%s%/' => Mage::getSingleton('core/date')->date('s'), '/%timestamp%/' => Mage::getSingleton('core/date')->timestamp(time()), '/%lastentityid%/' => $this->getVariableValue('last_entity_id', $exportArray, $filename, '%lastentityid%'), '/%orderid%/' => $this->getVariableValue('last_entity_id', $exportArray, $filename, '%orderid%'), '/%lastincrementid%/' => $this->getVariableValue('last_increment_id', $exportArray, $filename, '%lastincrementid%'), '/%firstincrementid%/' => $this->getVariableValue('first_increment_id', $exportArray, $filename, '%firstincrementid%'), '/%lastorderincrementid%/' => $this->getVariableValue('last_order_increment_id', $exportArray, $filename, '%lastorderincrementid%'), '/%realorderid%/' => $this->getVariableValue('last_increment_id', $exportArray, $filename, '%realorderid%'), '/%ordercount%/' => $this->getVariableValue('collection_count', $exportArray, $filename, '%ordercount%'), '/%collectioncount%/' => $this->getVariableValue('collection_count', $exportArray, $filename, '%collectioncount%'), '/%exportCountForObject%/' => $this->getVariableValue('export_count_for_object', $exportArray, $filename, '%exportCountForObject%'), '/%dailyExportCounter%/' => $this->getVariableValue('daily_export_counter', $exportArray, $filename, '%dailyExportCounter%'), '/%profileExportCounter%/' => $this->getVariableValue('profile_export_counter', $exportArray, $filename, '%profileExportCounter%'), '/%uuid%/' => uniqid(), '/%exportid%/' => $this->getVariableValue('export_id', $exportArray, $filename, '%exportid%'));
     // Ability to add custom variables to the filename using an event
     $transportObject = new Varien_Object();
     $transportObject->setCustomVariables(array());
     Mage::dispatchEvent('xtento_orderexport_replace_filename_variables_before', array('transport' => $transportObject));
     $replaceableVariables = array_merge($replaceableVariables, $transportObject->getCustomVariables());
     // Remember last exported ID
     Mage::unregister('last_exported_increment_id');
     Mage::register('last_exported_increment_id', $this->getVariableValue('last_increment_id', $exportArray, false, false));
     $filename = preg_replace(array_keys($replaceableVariables), array_values($replaceableVariables), $filename);
     return $filename;
 }