Ejemplo n.º 1
1
 /**
  * Handle scope row data
  *
  * @param string $type
  * @param array $row
  * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
  * @return boolean|Mage_Core_Model_Abstract
  */
 protected function _handleScopeRow($type, $row, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
 {
     $previousScope = array();
     if ($fixture->isScopeLocal() && $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED) !== null) {
         $previousScope = $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
     }
     if (isset($previousScope[$type][$row[$type . '_id']])) {
         return false;
     }
     $scopeModel = Mage::getModel($this->modelByType[$type]);
     $scopeModel->setData($row);
     // Change property for saving new objects with specified ids
     EcomDev_Utils_Reflection::setRestrictedPropertyValues($scopeModel->getResource(), array('_isPkAutoIncrement' => false));
     try {
         $scopeModel->isObjectNew(true);
         $scopeModel->save();
     } catch (Exception $e) {
         Mage::logException($e);
         // Skip duplicated key violation, since it might be a problem
         // of previous run with fatal error
         // Revert changed property
         EcomDev_Utils_Reflection::setRestrictedPropertyValues($scopeModel->getResource(), array('_isPkAutoIncrement' => true));
         // Load to make possible deletion
         $scopeModel->load($row[$type . '_id']);
     }
     // Revert changed property
     EcomDev_Utils_Reflection::setRestrictedPropertyValues($scopeModel->getResource(), array('_isPkAutoIncrement' => true));
     return $scopeModel;
 }
Ejemplo n.º 2
0
 /**
  * @return array
  */
 public function getPayoneInvoicePdf()
 {
     /**
      * @var $invoice Mage_Sales_Model_Order_Invoice
      */
     $invoice = Mage::registry('current_invoice');
     $order = $invoice->getOrder();
     $data = array('label' => $this->helperConfig()->__('Download PAYONE-Invoice'), 'class' => 'save', 'onclick' => 'setLocation(\'' . $this->getDownloadInvoiceUrl() . '\')');
     $disabled = false;
     try {
         $configPayment = $this->helperConfig()->getConfigPaymentMethodByOrder($order);
         if (!$configPayment || !$configPayment->isInvoiceTransmitEnabled() || $this->isAllowedAction('download_payone_invoice') === false) {
             $disabled = true;
         }
     } catch (Payone_Core_Exception_PaymentMethodConfigNotFound $e) {
         $disabled = true;
     } catch (Exception $e) {
         Mage::logException($e);
         $disabled = true;
     }
     if ($disabled) {
         $data['disabled'] = 1;
     }
     return $data;
 }
 /**
  * @return ICC_Ecodes_Model_Downloadable
  */
 public function remainingSerialsReport()
 {
     /** added for log tracking by anil 28 jul **/
     $currDate = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
     $fileName = date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));
     Mage::log("Controller Name : Ecode/Downloadable , Action Name : remainingSerialsReport , Start Time : {$currDate}", null, $fileName);
     /** end **/
     $threshold = Mage::getStoreConfig(self::XML_PATH_REPORT_THRESHOLD);
     $errors = array();
     if (!is_numeric($threshold) || $threshold < 0) {
         $error = "Threshold was not a positive integer.";
         $errors[] = $error;
         Mage::log("Error while attempting to run " . __METHOD__ . ". " . $error);
     } else {
         $notifications = $this->getCollection()->prepareForRemainingReport($threshold);
         if ($notifications->count()) {
             try {
                 $this->sendNotificationEmail($notifications);
             } catch (Exception $e) {
                 Mage::logException($e);
             }
         }
     }
     /** added for log tracking by anil 28 jul start **/
     $currDate = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
     Mage::log("Controller Name : Ecode/Downloadable , Action Name : remainingSerialsReport , End Time : {$currDate}", null, $fileName);
     /** end **/
     return $this;
 }
Ejemplo n.º 4
0
 public function cron()
 {
     if ($files = Mage::helper('cachewarm')->getMaps()) {
         Mage::helper('cachewarm')->unsMaps();
         foreach ($files as $file) {
             if (file_exists($file)) {
                 $xml = simplexml_load_file($file);
                 foreach ($xml as $sectionName => $sectionData) {
                     if ($sectionName == "url") {
                         try {
                             Mage::log($sectionData->loc, null, 'cachewarm.log', true);
                             $ch = curl_init();
                             curl_setopt($ch, CURLOPT_URL, (string) $sectionData->loc);
                             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                             curl_exec($ch);
                             curl_close($ch);
                         } catch (Exception $e) {
                             Mage::logException($e);
                             Mage::log('error: ' . $e->getMessage(), null, 'cachewarm.log', true);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Create Backup
  *
  * @return Mage_Log_Model_Cron
  */
 public function scheduledBackup()
 {
     if (!Mage::getStoreConfigFlag(self::XML_PATH_BACKUP_ENABLED)) {
         return $this;
     }
     if (Mage::getStoreConfigFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE)) {
         Mage::helper('backup')->turnOnMaintenanceMode();
     }
     $type = Mage::getStoreConfig(self::XML_PATH_BACKUP_TYPE);
     $this->_errors = array();
     try {
         $backupManager = Mage_Backup::getBackupInstance($type)->setBackupExtension(Mage::helper('backup')->getExtensionByType($type))->setTime(time())->setBackupsDir(Mage::helper('backup')->getBackupsDir());
         Mage::register('backup_manager', $backupManager);
         if ($type != Mage_Backup_Helper_Data::TYPE_DB) {
             $backupManager->setRootDir(Mage::getBaseDir())->addIgnorePaths(Mage::helper('backup')->getBackupIgnorePaths());
         }
         $backupManager->create();
         Mage::log(Mage::helper('backup')->getCreateSuccessMessageByType($type));
     } catch (Exception $e) {
         $this->_errors[] = $e->getMessage();
         $this->_errors[] = $e->getTrace();
         Mage::log($e->getMessage(), Zend_Log::ERR);
         Mage::logException($e);
     }
     if (Mage::getStoreConfigFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE)) {
         Mage::helper('backup')->turnOffMaintenanceMode();
     }
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * Create instance of entity adapter and returns it.
  *
  * @throws Mage_Core_Exception
  * @return Mage_ImportExport_Model_Import_Entity_Abstract
  */
 protected function _getEntityAdapter()
 {
     if (!$this->_entityAdapter) {
         $validTypes = Mage_ImportExport_Model_Config::getModels(self::CONFIG_KEY_ENTITIES);
         if (isset($validTypes[$this->getEntity()])) {
             try {
                 $this->_entityAdapter = Mage::getModel($validTypes[$this->getEntity()]['model']);
             } catch (Exception $e) {
                 Mage::logException($e);
                 Mage::throwException(Mage::helper('importexport')->__('Invalid entity model'));
             }
             if (!$this->_entityAdapter instanceof Mage_ImportExport_Model_Import_Entity_Abstract) {
                 Mage::throwException(Mage::helper('importexport')->__('Entity adapter object must be an instance of Mage_ImportExport_Model_Import_Entity_Abstract'));
             }
         } else {
             Mage::throwException(Mage::helper('importexport')->__('Invalid entity'));
         }
         // check for entity codes integrity
         if ($this->getEntity() != $this->_entityAdapter->getEntityTypeCode()) {
             Mage::throwException(Mage::helper('importexport')->__('Input entity code is not equal to entity adapter code'));
         }
         $this->_entityAdapter->setParameters($this->getData());
     }
     return $this->_entityAdapter;
 }
Ejemplo n.º 7
0
 /**
  * Initialize requested vendor object
  *
  * @return Ced_CsMarketplace_Model_Vendor
  */
 protected function _initVendor()
 {
     Mage::dispatchEvent('csmarketplace_controller_vshops_init_before', array('controller_action' => $this));
     if (!Mage::helper('csmarketplace/acl')->isEnabled()) {
         return false;
     }
     $shopUrl = Mage::getModel('csmarketplace/vendor')->getShopUrlKey($this->getRequest()->getParam('shop_url', ''));
     if (!strlen($shopUrl)) {
         return false;
     }
     $vendor = Mage::getModel('csmarketplace/vendor')->setStoreId(Mage::app()->getStore()->getId())->loadByAttribute('shop_url', $shopUrl);
     if (!Mage::helper('csmarketplace')->canShow($vendor)) {
         return false;
     } else {
         if (!Mage::helper('csmarketplace')->isShopEnabled($vendor)) {
             return false;
         }
     }
     //Mage::getSingleton('catalog/session')->setLastVisitedCategoryId($category->getId());
     Mage::register('current_vendor', $vendor);
     //Mage::register('current_entity_key', $category->getPath());
     try {
         Mage::dispatchEvent('csmarketplace_controller_vshops_init_after', array('vendor' => $vendor, 'controller_action' => $this));
     } catch (Mage_Core_Exception $e) {
         Mage::logException($e);
         return false;
     }
     return $vendor;
 }
Ejemplo n.º 8
0
 public function uploadPostAction()
 {
     try {
         if (!isset($_FILES['template'])) {
             throw new Mage_Exception($this->__("No template file selected"));
         }
         $file = $_FILES['template'];
         if ($file['error']['file'] !== UPLOAD_ERR_OK) {
             throw new Mage_Exception($this->__("Error when uploading template (#%s)", $file['error']['file']));
         }
         $template = $this->_initTemplate();
         $template->loadFromFile($file['tmp_name']['file']);
         $template->save();
         if (version_compare($template->getVersion(), Mage::helper('mzax_emarketing')->getVersion()) < 0) {
             $this->_getSession()->addWarning($this->__("The template you just uploaded was made with version %s, you only have version %s of Mzax Emarketing. This might cause an issue."));
         }
         $this->_getSession()->addSuccess($this->__("Template successfully uploaded."));
         $this->_redirect('*/*/edit', array('id' => $template->getId()));
         return;
     } catch (Mage_Exception $e) {
         $this->_getSession()->addError($e->getMessage());
     } catch (Exception $e) {
         if (Mage::getIsDeveloperMode()) {
             throw $e;
         }
         Mage::logException($e);
         $this->_getSession()->addError($this->__("There was an error uploading the template."));
     }
     $this->_redirect('*/*/index');
 }
Ejemplo n.º 9
0
 /**
  * @param $store
  * @param $items
  * @param $tplSuccess
  * @param $tplError
  * @return $this
  */
 public function sendFeedNotification($store, $items, $tplSuccess, $tplError)
 {
     $body = '';
     $hasError = false;
     $allowedKeys = array('entity_name', 'store_name', 'error_message');
     foreach ($items as $item) {
         if ($item['successfully']) {
             $itemMsg = $this->__($tplSuccess);
         } else {
             $itemMsg = $this->__($tplError);
             $hasError = true;
         }
         foreach ($allowedKeys as $key) {
             $value = isset($item[$key]) ? $item[$key] : '';
             $itemMsg = str_replace("{{$key}}", $value, $itemMsg);
         }
         $body .= $itemMsg . PHP_EOL;
     }
     $email = $this->_getConfig()->getNotificationRecipientEmail($store);
     $subject = $this->_getConfig()->getNotificationSubject();
     $subject .= $hasError ? $this->__('Failure') : $this->__('Success');
     $mail = new Zend_Mail();
     $mail->setFrom($this->_getConfig()->getDefaultSenderEmail(), $this->_getConfig()->getDefaultSenderName());
     $mail->addTo($email);
     $mail->setSubject($subject);
     $mail->setBodyHtml(nl2br($body));
     try {
         $mail->send();
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return $this;
 }
 public function saveAction()
 {
     if ($this->getRequest()->getPost()) {
         try {
             $data = $this->getRequest()->getPost();
             $id = $this->getRequest()->getParam('id');
             $respricedate = Mage::getModel('payperrentals/reservationpricesdates');
             if ($id) {
                 $respricedate->load($id);
             } else {
                 unset($data['id']);
             }
             if ($data) {
                 if (array_key_exists('repeat_days', $data)) {
                     $data['repeat_days'] = implode(',', $data['repeat_days']);
                 }
                 $respricedate->setData($data);
                 $respricedate->save();
             }
             Mage::getSingleton('adminhtml/session')->addSuccess('Saved');
             Mage::getSingleton('adminhtml/session')->setFormData(false);
             $this->_redirect('*/*/index');
         } catch (Exception $e) {
             $this->_getSession()->addError(Mage::helper('payperrentals')->__('An error occurred while saving the data. Please review the log and try again.'));
             Mage::logException($e);
             $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
             return $this;
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * This methods overwrites Mage_Eav_Model_Entity_Attribute_Backend_Abstract::afterSave
  * in a bad way, just because the "$uploader = new class".
  * 
  * @param type $object
  * @return type
  */
 public function afterSave($object)
 {
     if (!Mage::helper('magefm_cdn')->isEnabled()) {
         return parent::afterSave($object);
     }
     $value = $object->getData($this->getAttribute()->getName());
     if (is_array($value) && !empty($value['delete'])) {
         $object->setData($this->getAttribute()->getName(), '');
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
         return;
     }
     $path = 'catalog' . DS . 'category';
     try {
         $uploader = new MageFM_CDN_Model_Uploader($this->getAttribute()->getName());
         $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
         $uploader->setAllowRenameFiles(true);
         $result = $uploader->save($path);
         $object->setData($this->getAttribute()->getName(), $result['file']);
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
     } catch (Exception $e) {
         if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
             Mage::logException($e);
         }
         /** @TODO ??? */
         return;
     }
 }
Ejemplo n.º 12
0
 /**
  * Response action.
  * Action for Authorize.net SIM Relay Request.
  */
 public function responseAction()
 {
     $data = $this->getRequest()->getPost();
     /* @var $paymentMethod Mage_Authorizenet_Model_DirectPost */
     $paymentMethod = Mage::getModel('authorizenet/directpost');
     $result = array();
     if (!empty($data['x_invoice_num'])) {
         $result['x_invoice_num'] = $data['x_invoice_num'];
     }
     try {
         if (!empty($data['store_id'])) {
             $paymentMethod->setStore($data['store_id']);
         }
         $paymentMethod->process($data);
         $result['success'] = 1;
     } catch (Mage_Core_Exception $e) {
         Mage::logException($e);
         $result['success'] = 0;
         $result['error_msg'] = $e->getMessage();
     } catch (Exception $e) {
         Mage::logException($e);
         $result['success'] = 0;
         $result['error_msg'] = $this->__('There was an error processing your order. Please contact us or try again later.');
     }
     if (!empty($data['controller_action_name'])) {
         if (!empty($data['key'])) {
             $result['key'] = $data['key'];
         }
         $result['controller_action_name'] = $data['controller_action_name'];
         $result['is_secure'] = isset($data['is_secure']) ? $data['is_secure'] : false;
         $params['redirect'] = Mage::helper('authorizenet')->getRedirectIframeUrl($result);
     }
     $block = $this->_getIframeBlock()->setParams($params);
     $this->getResponse()->setBody($block->toHtml());
 }
Ejemplo n.º 13
0
 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;
 }
Ejemplo n.º 14
0
 public function updateRegistryData($data)
 {
     try {
         if (!empty($data)) {
             $description = $data['msg2'];
             $link = 'Apply';
             $title = 'Item Drop Notification';
             $linkurl = '[[pdurl]]';
             $coupon = implode(" ", $data['coupons']);
             $theme = $data['theme'];
             $NotificationId = Mage::helper('webengage_coup')->NotificationCreate($title, $description, $link, $linkurl, $theme);
             if ($NotificationId !== null) {
                 $this->setTitle($title);
                 $this->setDescription($description);
                 $this->setLink($link);
                 $this->setCoupon($coupon);
                 $this->setLinkurl($linkurl);
                 $this->setTheme($theme);
                 $this->setIdd($NotificationId);
                 return 1;
             } else {
                 throw new Exception("Error Processing Request: Insufficient Data Provided");
             }
         }
     } catch (Exception $e) {
         Mage::logException($e);
         return 0;
     }
 }
 public function authenticate()
 {
     $state = $this->getOAuthState();
     $consumer = $this->_getOAuthConsumer();
     try {
         switch ($state) {
             case self::OAUTH_STATE_NO_TOKEN:
                 $requestToken = $this->getRequestToken();
                 $this->setOAuthState(self::OAUTH_STATE_REQUEST_TOKEN);
                 $consumer->redirect();
                 return self::OAUTH_STATE_REQUEST_TOKEN;
                 break;
             case self::OAUTH_STATE_REQUEST_TOKEN:
                 $accessToken = $this->getAccessToken($this->getRequestToken());
                 $this->setAuthorizedToken($accessToken);
                 $this->setOAuthState(self::OAUTH_STATE_ACCESS_TOKEN);
                 return self::OAUTH_STATE_ACCESS_TOKEN;
                 break;
             case self::OAUTH_STATE_ACCESS_TOKEN:
                 return self::OAUTH_STATE_ACCESS_TOKEN;
             default:
                 $this->resetSessionParams();
                 return self::OAUTH_STATE_NO_TOKEN;
                 return;
                 break;
         }
     } catch (Zend_Oauth_Exception $e) {
         $this->resetSessionParams();
         Mage::logException($e);
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return self::OAUTH_STATE_NO_TOKEN;
 }
Ejemplo n.º 16
0
 protected function _getRewriter($code, $config)
 {
     if (!isset($this->_rewriters[$code])) {
         if (!isset($config['model'])) {
             return false;
         }
         try {
             $rewriter = Mage::getModel($config['model']);
         } catch (Exception $e) {
             Mage::logException($e);
             return false;
         }
         $rewriter->setId($code)->setPriority(isset($config['priority']) ? intval($config['priority']) : 0)->setDisplayErrors(isset($config['display_errors']) ? (bool) $config['display_errors'] : false)->setLogErrors(isset($config['log_errors']) ? (bool) $config['log_errors'] : false);
         if ($rewriter->getDisplayErrors()) {
             $rewriter->setDisplayErrorsIfSuccess(isset($config['display_errors_if_success']) ? (bool) $config['display_errors_if_success'] : false);
         } else {
             $rewriter->setDisplayErrorsIfSuccess(false);
         }
         if ($rewriter->getLogErrors()) {
             $rewriter->setLogErrorsIfSuccess(isset($config['log_errors_if_success']) ? (bool) $config['log_errors_if_success'] : false);
         } else {
             $rewriter->setLogErrorsIfSuccess(false);
         }
         $this->_rewriters[$code] = $rewriter;
     }
     return $this->_rewriters[$code];
 }
Ejemplo n.º 17
0
 public function process(array $csvData, $cid, $imageDir)
 {
     $cnt = count($csvData);
     $importDir = Mage::getBaseDir() . DS . 'media' . DS . 'marketplace' . DS . $cid . DS . $imageDir . DS;
     if ($cnt > 1) {
         for ($i = 1; $i < $cnt; $i++) {
             try {
                 $sku = $csvData[$i][0];
                 $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
                 $fileName = trim($csvData[$i][11]);
                 $filePath = $importDir . $fileName;
                 if (file_exists($filePath) && $fileName != '') {
                     $types = array('image', 'small_image', 'thumbnail');
                     foreach ($types as $type) {
                         $product->addImageToMediaGallery($filePath, array($type), false);
                     }
                     $mediaGallery = $product->getMediaGallery();
                     if (isset($mediaGallery['images'])) {
                         foreach ($mediaGallery['images'] as $key => $image) {
                             Mage::getSingleton('catalog/product_action')->updateAttributes(array($product->getId()), array($types[$key] => $image['file']), 0);
                         }
                     }
                     $product->save();
                     unlink($filePath);
                 } else {
                     $message = 'Image does not exist for sku ' . $sku;
                     Mage::log($message, null, 'sellerimages_debug.log', true);
                 }
             } catch (Exception $e) {
                 Mage::logException($e);
             }
         }
     }
     return true;
 }
Ejemplo n.º 18
0
 /**
  * Clear SagePaySuite session when loading onepage checkout
  */
 public function controllerOnePageClear($o)
 {
     /**
      * Delete register and guest cards when loading checkout
      */
     try {
         $sessionCards = Mage::helper('sagepaysuite/token')->getSessionTokens();
         if ($sessionCards->getSize() > 0) {
             foreach ($sessionCards as $_c) {
                 if ($_c->getCustomerId() == 0) {
                     $delete = Mage::getModel('sagepaysuite/sagePayToken')->removeCard($_c->getToken(), $_c->getProtocol());
                     if ($delete['Status'] == 'OK') {
                         $_c->delete();
                     }
                 }
             }
         }
     } catch (Exception $ex) {
         Mage::logException($ex);
     }
     /**
      * Delete register and guest cards when loading checkout
      */
     $this->getSession()->clear();
 }
Ejemplo n.º 19
0
 /**
  * This is a straigh copy/paste of
  *
  *   Mage_Catalog_ProductController::viewAction()
  *
  * Only change is that I replaced the $viewHelper so that we could
  * hook into prepareAndRender()
  */
 public function previewAction()
 {
     // Get initial data from request
     $categoryId = (int) $this->getRequest()->getParam('category', false);
     $productId = (int) $this->getRequest()->getParam('id');
     $specifyOptions = $this->getRequest()->getParam('options');
     // Prepare helper and params
     $viewHelper = Mage::helper('tadic_avp/catalog_product_view');
     $params = new Varien_Object();
     $params->setCategoryId($categoryId);
     $params->setSpecifyOptions($specifyOptions);
     // Render page
     try {
         $viewHelper->prepareAndRender($productId, $this, $params);
     } catch (Exception $e) {
         if ($e->getCode() == $viewHelper->ERR_NO_PRODUCT_LOADED) {
             if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) {
                 $this->_redirect('');
             } elseif (!$this->getResponse()->isRedirect()) {
                 $this->_forward('noRoute');
             }
         } else {
             Mage::logException($e);
             $this->_forward('noRoute');
         }
     }
 }
Ejemplo n.º 20
0
 /**
  * @event controller_action_predispatch
  * @param Varien_Event_Observer $observer
  */
 public function addMethodsToConfig(Varien_Event_Observer $observer)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         $store = Mage::getSingleton('adminhtml/session_quote')->getStore();
     } else {
         $store = Mage::app()->getStore();
     }
     // Add OneClick payment methods
     if (Mage::getStoreConfigFlag('payment/adyen_oneclick/active', $store)) {
         try {
             $this->_addOneClickMethodsToConfig($store);
         } catch (Exception $e) {
             $store->setConfig('payment/adyen_oneclick/active', 0);
             Mage::logException($e);
         }
     }
     if (Mage::getStoreConfigFlag('payment/adyen_hpp/active', $store)) {
         try {
             $this->_addHppMethodsToConfig($store);
         } catch (Exception $e) {
             $store->setConfig('payment/adyen_hpp/active', 0);
             Mage::logException($e);
         }
     }
 }
Ejemplo n.º 21
0
 public function indexAction()
 {
     // init category
     $categoryId = (int) Mage::app()->getStore()->getRootCategoryId();
     if (!$categoryId) {
         $this->_forward('noRoute');
         return;
     }
     $category = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($categoryId);
     Mage::register('current_category', $category);
     Mage::getSingleton('catalog/session')->setLastVisitedCategoryId($category->getId());
     // need to prepare layer params
     try {
         Mage::dispatchEvent('catalog_controller_category_init_after', array('category' => $category, 'controller_action' => $this));
     } catch (Mage_Core_Exception $e) {
         Mage::logException($e);
         return;
     }
     // observer can change value
     if (!$category->getId()) {
         $this->_forward('noRoute');
         return;
     }
     $this->loadLayout();
     $this->checkAddRwdBlocks();
     $this->renderLayout();
 }
Ejemplo n.º 22
0
 /**
  * @param bool $deleteSource
  *
  * @return bool
  */
 public function mergeCategories($deleteSource = false)
 {
     $this->_deleteSource = $deleteSource;
     try {
         // Check if both categories exist
         if (!$this->_source->getId() || !$this->_target->getId()) {
             return false;
         }
         $this->_moveProducts();
         $this->_moveChildrenCategories();
         // Just delete a category which is not parent of the target
         if ($this->_deleteSource && !in_array($this->_source->getId(), $this->_target->getParentIds())) {
             $this->_source->delete();
         }
         /** @var $index Mage_Index_Model_Process */
         $index = Mage::getModel('index/process')->load('catalog_category_product', 'indexer_code');
         if ($index->getId() && $index->getMode() == Mage_Index_Model_Process::MODE_REAL_TIME) {
             $index->reindexEverything();
         }
         Mage::dispatchEvent('mkleine_category_merge_finished', array('source_category' => $this->_source, 'target_category' => $this->_target));
         return true;
     } catch (Exception $e) {
         Mage::logException($e);
         return false;
     }
 }
Ejemplo n.º 23
0
 protected function generateStoreCss($type, $storeCode)
 {
     if (!Mage::app()->getStore($storeCode)->getIsActive()) {
         return;
     }
     $str1 = '_' . $storeCode;
     $str2 = $type . $str1 . '.css';
     $str3 = Mage::helper('mango/cssconfig')->getCssConfigDir() . $str2;
     $str4 = 'mango/css/' . $type . '.phtml';
     Mage::register('cssgen_store', $storeCode);
     try {
         $block = Mage::app()->getLayout()->createBlock("core/template")->setData('area', 'frontend')->setTemplate($str4)->toHtml();
         if (empty($block)) {
             throw new Exception(Mage::helper('mango')->__("Template file is empty or doesn't exist: %s", $str4));
         }
         $file = new Varien_Io_File();
         $file->setAllowCreateFolders(true);
         $file->open(array('path' => Mage::helper('mango/cssconfig')->getCssConfigDir()));
         $file->streamOpen($str3, 'w+');
         $file->streamLock(true);
         $file->streamWrite($block);
         $file->streamUnlock();
         $file->streamClose();
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mango')->__('Failed generating CSS file: %s in %s', $str2, Mage::helper('mango/cssconfig')->getCssConfigDir()) . '<br/>Message: ' . $e->getMessage());
         Mage::logException($e);
     }
     Mage::unregister('cssgen_store');
 }
Ejemplo n.º 24
0
 /**
  * Save uploaded file and set its name to category
  *
  * @param Varien_Object $object
  */
 public function afterSave($object)
 {
     $value = $object->getData($this->getAttribute()->getName());
     if (is_array($value) && !empty($value['delete'])) {
         $object->setData($this->getAttribute()->getName(), '');
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
         return;
     }
     $path = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
     try {
         $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
         $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
         $uploader->setAllowRenameFiles(true);
         $uploader->addValidateCallback(Mage_Core_Model_File_Validator_Image::NAME, new Mage_Core_Model_File_Validator_Image(), "validate");
         $result = $uploader->save($path);
         $object->setData($this->getAttribute()->getName(), $result['file']);
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
     } catch (Exception $e) {
         if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
             Mage::logException($e);
         }
         /** @TODO ??? */
         return;
     }
 }
Ejemplo n.º 25
0
 public function removecreditAction()
 {
     $this->loadLayout();
     $this->renderLayout();
     $session = $this->_getSession();
     if (!($order = $this->_initOrder())) {
         return;
     }
     $payment = $order->getPayment();
     if ($payment->getMethod() == 'gwap_cc' || $payment->getMethod() == 'gwap_oneclick' || $payment->getMethod() == 'gwap_2cc') {
         $log = Mage::getModel('allpago_mc/log');
         try {
             $payment->getMethodInstance()->removeCredit($order);
             $log->add($order->getId(), 'Payment', 'removecredit()', 'reversed', 'Pagamento cancelado');
             $this->_getSession()->addSuccess($this->__('O pagamento foi estornado com sucesso.'));
         } catch (Mage_Core_Exception $e) {
             $this->_getSession()->addError($e->getMessage());
             $log->add($order->getId(), 'Payment', 'removecredit()', 'error', 'Pagamento não cancelado', $e->getMessage());
         } catch (Exception $e) {
             $this->_getSession()->addError($this->__('Falha ao estornar pagamento. Verifique os logs de erro.'));
             Mage::logException($e);
             $log->add($order->getId(), 'Payment', 'removecredit()', 'error', 'Pagamento não cancelado', $e->getMessage());
         }
     } else {
         $session->addError(Mage::helper("gwap")->__("Este tipo de pagamento não pode ser estornado"));
     }
     $this->_redirect('adminhtml/sales_order/view', array('order_id' => $order->getId()));
 }
Ejemplo n.º 26
0
 /**
  * Save ACL resources
  *
  * @param Mage_Admin_Model_Rules $rule
  */
 public function saveRel(Mage_Admin_Model_Rules $rule)
 {
     try {
         $this->_getWriteAdapter()->beginTransaction();
         $roleId = $rule->getRoleId();
         $this->_getWriteAdapter()->delete($this->getMainTable(), "role_id = {$roleId}");
         $postedResources = $rule->getResources();
         if ($postedResources) {
             $row = array('role_type' => 'G', 'resource_id' => 'all', 'privileges' => '', 'assert_id' => 0, 'role_id' => $roleId, 'permission' => 'allow');
             // If all was selected save it only and nothing else.
             if ($postedResources === array('all')) {
                 $this->_getWriteAdapter()->insert($this->getMainTable(), $row);
             } else {
                 foreach (Mage::getModel('admin/roles')->getResourcesList2D() as $index => $resName) {
                     $row['permission'] = in_array($resName, $postedResources) ? 'allow' : 'deny';
                     $row['resource_id'] = trim($resName, '/');
                     $this->_getWriteAdapter()->insert($this->getMainTable(), $row);
                 }
             }
         }
         $this->_getWriteAdapter()->commit();
     } catch (Mage_Core_Exception $e) {
         $this->_getWriteAdapter()->rollBack();
         throw $e;
     } catch (Exception $e) {
         $this->_getWriteAdapter()->rollBack();
         Mage::logException($e);
     }
 }
Ejemplo n.º 27
0
 protected function _generateStoreCss($x0b, $x0d)
 {
     if (!Mage::app()->getStore($x0d)->getIsActive()) {
         return;
     }
     $x11 = '_' . $x0d;
     $x12 = $x0b . $x11 . '.css';
     $x13 = Mage::helper('ultimo/cssgen')->getGeneratedCssDir() . $x12;
     $x14 = Mage::helper('ultimo/cssgen')->getTemplatePath() . $x0b . '.phtml';
     Mage::register('cssgen_store', $x0d);
     try {
         $x15 = Mage::app()->getLayout()->createBlock("core/template")->setData('area', 'frontend')->setTemplate($x14)->toHtml();
         if (empty($x15)) {
             throw new Exception(Mage::helper('ultimo')->__("Template file is empty or doesn't exist: %s", $x14));
         }
         $x16 = new Varien_Io_File();
         $x16->setAllowCreateFolders(true);
         $x16->open(array('path' => Mage::helper('ultimo/cssgen')->getGeneratedCssDir()));
         $x16->streamOpen($x13, 'w+', 0777);
         $x16->streamLock(true);
         $x16->streamWrite($x15);
         $x16->streamUnlock();
         $x16->streamClose();
     } catch (Exception $x17) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ultimo')->__('Failed generating CSS file: %s in %s', $x12, Mage::helper('ultimo/cssgen')->getGeneratedCssDir()) . '<br/>Message: ' . $x17->getMessage());
         Mage::logException($x17);
     }
     Mage::unregister('cssgen_store');
 }
 public function checkoutCartSaveAfter($observer)
 {
     if (Mage::helper('awafptc')->extensionDisabled()) {
         return $this;
     }
     $cart = $observer->getCart();
     $store = Mage::app()->getStore();
     $rulesCollection = Mage::getResourceModel('awafptc/rule')->getActiveRulesCollection($store);
     foreach ($rulesCollection as $ruleModel) {
         $ruleModel->load($ruleModel->getId());
         if (!$ruleModel->validate($cart)) {
             continue;
         }
         if (isset($_stopFlag)) {
             break;
         }
         if ($ruleModel->getStopRulesProcessing()) {
             $_stopFlag = true;
         }
         if ($ruleModel->getShowPopup()) {
             continue;
         }
         if ((Mage::helper('awafptc')->getDeclineRuleCookie($ruleModel->getId()) || Mage::registry('rule_decline') == $ruleModel->getId()) && !Mage::registry('ignore_decline')) {
             continue;
         }
         try {
             $ruleModel->apply($cart, null);
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
     $cart->getQuote()->unsTotalsCollectedFlag()->collectTotals()->save();
     return $this;
 }
Ejemplo n.º 29
0
 /**
  * @param type $actionName
  * @param type $varienObj
  * @return type 
  */
 public function authenticate($actionName, $varienObj)
 {
     $authStatus = false;
     switch ($actionName) {
         case 'success':
             $authStatus = $this->_signAuthenticate($varienObj);
             break;
         default:
             $authStatus = $this->_httpAuthenticate($varienObj);
             if ($authStatus === false) {
                 header('HTTP/1.1 401 Unauthorized', true, 401);
                 header('WWW-Authenticate: Basic realm="Notifications"');
                 echo "";
                 exit;
             }
             break;
     }
     try {
         if (false === $authStatus) {
             throw new SoapFault('200', Mage::helper('adyen')->__('Username or Password is incorrect, please contact Adyen for support!'));
         }
     } catch (SoapFault $e) {
         Mage::logException($e);
     }
     return $authStatus;
 }
Ejemplo n.º 30
0
 /**
  * keep compatible with the Zend_Pdf way of doing things
  * collect input for later processing with render()
  *
  * @param array $input    array of items to print
  * @param array $orderIds array of order ids
  *
  * @return Fooman_PdfCustomiser_Model_Abstract | Zend_Pdf
  */
 public function getPdf($input = array(), $orderIds = null)
 {
     if (self::COMPAT_MODE) {
         try {
             $newPdf = new Zend_Pdf();
             $extractor = new Zend_Pdf_Resource_Extractor();
             if (!empty($orderIds)) {
                 $origPdf = $this->renderPdf(null, $orderIds, null, true);
             } else {
                 $origPdf = $this->renderPdf($input, $orderIds, null, true);
             }
             if ($origPdf->getPdfAnyOutput()) {
                 $pdfString = $origPdf->Output('output.pdf', 'S');
                 $tcpdf = Zend_Pdf::parse($pdfString);
                 foreach ($tcpdf->pages as $p) {
                     $newPdf->pages[] = $extractor->clonePage($p);
                 }
             }
             return $newPdf;
         } catch (Exception $e) {
             Mage::logException($e);
         }
     } else {
         $this->pages[] = array('instance' => $this, 'objectArray' => $input, 'orderIds' => $orderIds);
         return $this;
     }
 }