Example #1
0
 public function getRemoveUrl()
 {
     /** @var $category Mage_Catalog_Model_Category */
     $category = Mage::registry('current_category');
     /** @var $landingPage Hackathon_Layeredlanding_Model_Layeredlanding */
     $landingPage = Mage::registry('current_landingpage');
     if ($category->getId() && $landingPage && $landingPage->getId()) {
         $query = array($this->getFilter()->getRequestVar() => $this->getFilter()->getResetValue());
         $params['_current'] = true;
         $params['_use_rewrite'] = true;
         $params['_query'] = $query;
         $params['_escape'] = true;
         $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode(10, $this->getFilter()->getRequestVar());
         $attributeIds = array();
         foreach ($landingPage->getAttributes() as $attribute) {
             $attributeIds[] = $attribute->getAttributeId();
         }
         if ($attributeModel->getId() && in_array($attributeModel->getAttributeId(), $attributeIds)) {
             $parameters = parse_url(Mage::getUrl('*/*/*', $params), PHP_URL_QUERY);
             $categoryUrl = parse_url($category->getUrl(), PHP_URL_PATH);
             return sprintf('%s?%s', $categoryUrl, $parameters);
         }
         return Mage::getUrl('*/*/*', $params);
     }
     return parent::getRemoveUrl();
 }
Example #2
0
 protected function _toHtml()
 {
     $rssObj = Mage::getModel('rss/rss');
     $order = Mage::registry('current_order');
     $title = Mage::helper('rss')->__('Order # %s Notification(s)', $order->getIncrementId());
     $newurl = Mage::getUrl('sales/order/view', array('order_id' => $order->getId()));
     $data = array('title' => $title, 'description' => $title, 'link' => $newurl, 'charset' => 'UTF-8');
     $rssObj->_addHeader($data);
     $resourceModel = Mage::getResourceModel('rss/order');
     $results = $resourceModel->getAllCommentCollection($order->getId());
     if ($results) {
         foreach ($results as $result) {
             $urlAppend = 'view';
             $type = $result['entity_type_code'];
             if ($type && $type != 'order') {
                 $urlAppend = $type;
             }
             $type = Mage::helper('rss')->__(ucwords($type));
             $title = Mage::helper('rss')->__('Details for %s #%s', $type, $result['increment_id']);
             $description = '<p>' . Mage::helper('rss')->__('Notified Date: %s<br/>', $this->formatDate($result['created_at'])) . Mage::helper('rss')->__('Comment: %s<br/>', $result['comment']) . '</p>';
             $url = Mage::getUrl('sales/order/' . $urlAppend, array('order_id' => $order->getId()));
             $data = array('title' => $title, 'link' => $url, 'description' => $description);
             $rssObj->_addEntry($data);
         }
     }
     $title = Mage::helper('rss')->__('Order #%s created at %s', $order->getIncrementId(), $this->formatDate($order->getCreatedAt()));
     $url = Mage::getUrl('sales/order/view', array('order_id' => $order->getId()));
     $description = '<p>' . Mage::helper('rss')->__('Current Status: %s<br/>', $order->getStatusLabel()) . Mage::helper('rss')->__('Total: %s<br/>', $order->formatPrice($order->getGrandTotal())) . '</p>';
     $data = array('title' => $title, 'link' => $url, 'description' => $description);
     $rssObj->_addEntry($data);
     return $rssObj->createRssXml();
 }
Example #3
0
 protected function _toHtml()
 {
     $storeId = $this->_getStoreId();
     $newurl = Mage::getUrl('rss/catalog/new/store_id/' . $storeId);
     $title = Mage::helper('rss')->__('New Products from %s', Mage::app()->getStore()->getGroup()->getName());
     $lang = Mage::getStoreConfig('general/locale/code');
     $rssObj = Mage::getModel('rss/rss');
     $data = array('title' => $title, 'description' => $title, 'link' => $newurl, 'charset' => 'UTF-8', 'language' => $lang);
     $rssObj->_addHeader($data);
     /*
     oringinal price - getPrice() - inputed in admin
     special price - getSpecialPrice()
     getFinalPrice() - used in shopping cart calculations
     */
     $product = Mage::getModel('catalog/product');
     $todayDate = $product->getResource()->formatDate(time());
     $products = $product->getCollection()->setStoreId($storeId)->addStoreFilter()->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))->addAttributeToFilter(array(array('attribute' => 'news_to_date', 'date' => true, 'from' => $todayDate), array('attribute' => 'news_to_date', 'is' => new Zend_Db_Expr('null'))), '', 'left')->addAttributeToSort('news_from_date', 'desc')->addAttributeToSelect(array('name', 'short_description', 'description', 'thumbnail'), 'inner')->addAttributeToSelect(array('price', 'special_price', 'special_from_date', 'special_to_date', 'msrp_enabled', 'msrp_display_actual_price_type', 'msrp'), 'left')->applyFrontendPriceLimitations();
     $products->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
     /*
     using resource iterator to load the data one by one
     instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
     */
     Mage::getSingleton('core/resource_iterator')->walk($products->getSelect(), array(array($this, 'addNewItemXmlCallback')), array('rssObj' => $rssObj, 'product' => $product));
     return $rssObj->createRssXml();
 }
Example #4
0
 public function sendMailAuthentication($email, $method)
 {
     //random code
     $account = Mage::getSingleton('affiliateplus/session')->getAccount();
     $length = 6;
     $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
     $str = '';
     if ($this->getId()) {
         $str = $this->getInfo();
     } else {
         $count = strlen($charset);
         while ($length--) {
             $str .= $charset[mt_rand(0, $count - 1)];
         }
     }
     $sendTo = array('email' => $email, 'name' => $account->getName());
     $store = Mage::app()->getStore();
     /*send authentication code to email*/
     $link = Mage::getUrl('*/*/verifyCode', array('account_id' => $account->getId(), 'payment_method' => $method, 'email' => $email, 'authentication_code' => $str, 'from' => 'email'));
     $translate = Mage::getSingleton('core/translate');
     $translate->setTranslateInline(false);
     $template = Mage::getStoreConfig(self::TEMPLATE_VERIFY_EMAIL, $store->getId());
     $sender = Mage::helper('affiliateplus')->getSenderContact();
     $mailSubject = 'Verify Email Payment';
     $mailTemplate = Mage::getModel('core/email_template');
     try {
         $mailTemplate->setEmailSubject($mailSubject)->sendTransactional($template, $sender, $sendTo['email'], $sendTo['name'], array('store' => $store, 'sender_name' => $sender['name'], 'code' => $str, 'link' => $link, 'name' => $account->getName()), $store->getId());
         return $str;
         $translate->setTranslateInline(true);
     } catch (Exception $e) {
     }
     return;
     /*edit send mail*/
 }
Example #5
0
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $identifier = trim($request->getPathInfo(), '/');
     /* @var $parser Hackathon_Layeredlanding_Model_Layeredlanding */
     $landingPage = Mage::getModel('layeredlanding/layeredlanding')->loadByUrl($identifier);
     if (!$landingPage->getId()) {
         return false;
     }
     Mage::register('current_landingpage', $landingPage);
     Mage::app()->getStore()->setConfig(Mage_Catalog_Helper_Category::XML_PATH_USE_CATEGORY_CANONICAL_TAG, 0);
     // disable canonical tag
     // if successfully gained url parameters, use them and dispatch ActionController action
     $categoryIdsValue = $landingPage->getCategoryIds();
     $categoryIds = explode(',', $categoryIdsValue);
     $firstCategoryId = $categoryIds[0];
     $request->setRouteName('catalog')->setModuleName('catalog')->setControllerName('category')->setActionName('view')->setParam('id', $firstCategoryId);
     /** @var $attribute Hackathon_Layeredlanding_Model_Attributes */
     foreach ($landingPage->getAttributes() as $attribute) {
         $attr = Mage::getModel('eav/entity_attribute')->load($attribute->getAttributeId());
         $request->setParam($attr->getAttributeCode(), $attribute->getValue());
     }
     $controllerClassName = $this->_validateControllerClassName('Mage_Catalog', 'category');
     $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $this->getFront()->getResponse());
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     // dispatch action
     $request->setDispatched(true);
     $controllerInstance->dispatch('view');
     return true;
 }
Example #6
0
 private function initSession($order, $enc_key, $itemid)
 {
     $paytype = Mage::getStoreConfig('payment/payture/paytype');
     $request = array('SessionType' => $paytype, 'OrderId' => $order->getId(), 'Amount' => $order->getGrandTotal() * 100, 'Total' => $order->getGrandTotal(), 'IP' => $order->getRemoteIp(), 'Url' => Mage::getUrl('payture/payment/result/', array('_secure' => true, 'order' => $enc_key)));
     //add product names
     $products = '';
     $items = $order->getItemsCollection();
     foreach ($items as $item) {
         if ($item->getOriginalPrice() > 0) {
             $products .= $item->getName() . ', ';
         }
     }
     if (substr($products, strlen($products) - 2, 2) == ', ') {
         $products = substr($products, 0, strlen($products) - 2);
     }
     $request['Product'] = $products;
     $result = $this->requestApiGet(Mage::helper('payture')->getHost() . 'Init', $request);
     Mage::helper('payture')->addLog($result);
     $xml = simplexml_load_string($result);
     if ((bool) $xml["Success"][0] == true) {
         if ($xml["SessionId"][0]) {
             $item = Mage::getModel('payture/keys')->load($itemid);
             $item->setSessionid($xml["SessionId"][0]);
             $item->setPaytype($paytype);
             $item->setState('New');
             $item->setDate(Mage::getModel('core/date')->date('Y-m-d H:i:s'));
             $item->save();
             return $xml["SessionId"][0];
         }
     } else {
         $session = Mage::getSingleton('checkout/session');
         $session->addError($xml["ErrCode"][0]);
         return false;
     }
 }
Example #7
0
 public function doGeneralAssert($textToCheck)
 {
     $this->assertContains(Mage::getUrl('checkout/cart'), $textToCheck);
     $this->assertContains(Mage::getUrl('checkout'), $textToCheck);
     $this->assertContains(Mage::getUrl('customer/account'), $textToCheck);
     $this->assertContains("</body>", $textToCheck);
 }
Example #8
0
 public function getSavePdfUrl($front = 'aitcg')
 {
     if (Mage::app()->getStore()->getConfig('catalog/aitcg/aitcg_enable_svg_to_pdf') == 1) {
         return Mage::getUrl($front . '/index/pdf');
     }
     return false;
 }
Example #9
0
 public function indexAction()
 {
     echo "<h2>This tests points expiry </h2>";
     echo "<a href='" . Mage::getUrl('rewards/debug_expiry/testCron') . "'>Run Daily Cron Expiry Check</a> - This will send out any e-mails, write to any logs, expire any points, etc. <BR />";
     echo "<a href='" . Mage::getUrl('rewards/debug_expiry/expirePoints') . "'>VIEW points balance expiry info for customer id #1 </a> (or customer id specified as customer_id in the url param)<BR />";
     exit;
 }
 /**
  * Authorize Login Token
  *
  * Create account and/or log user in.
  */
 public function authorizeAction()
 {
     $token = $this->getRequest()->getParam('token');
     if (!$token) {
         $token = $this->getRequest()->getParam('access_token');
     }
     if ($token) {
         $customer = Mage::getModel('amazon_login/customer')->loginWithToken($token);
         if ($customer->getId()) {
             $this->_redirectUrl(Mage::helper('customer')->getDashboardUrl());
         } else {
             Mage::getSingleton('customer/session')->addError('Unable to log in with Amazon.');
             if ($referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME)) {
                 $referer = Mage::helper('core')->urlDecode($referer);
                 $this->_redirectUrl($referer);
             }
         }
     } else {
         if ($error = $this->getRequest()->getParam('error_description')) {
             Mage::getSingleton('customer/session')->addError('Unable to log in with Amazon: ' . htmlspecialchars($error));
             $this->_redirectUrl(Mage::getUrl(''));
         } else {
             $this->loadLayout();
             $this->_initLayoutMessages('customer/session');
             $this->renderLayout();
         }
     }
 }
Example #11
0
 protected function AutoSubmit()
 {
     $oOrder = $this->_getOrder();
     $oBilling = $oOrder->getBillingAddress();
     $szHtml = '';
     if ($oOrder) {
         try {
             $oPayment = new AllInOne();
             $oPayment->ServiceURL = $this->_getConfigData('test_mode') ? 'http://payment-stage.allpay.com.tw/Cashier/AioCheckOut' : 'https://payment.allpay.com.tw/Cashier/AioCheckOut';
             $oPayment->HashKey = $this->_getConfigData('hash_key');
             $oPayment->HashIV = $this->_getConfigData('hash_iv');
             $oPayment->MerchantID = $this->_getConfigData('merchant_id');
             $oPayment->Send['ReturnURL'] = Mage::getUrl('alipay/processing/response');
             $oPayment->Send['ClientBackURL'] = Mage::getUrl('');
             $oPayment->Send['OrderResultURL'] = Mage::getUrl('alipay/processing/result');
             $oPayment->Send['MerchantTradeNo'] = ($this->_getConfigData('test_mode') ? $this->_getConfigData('test_order_prefix') : '') . $oOrder->getIncrementId();
             $oPayment->Send['MerchantTradeDate'] = date('Y/m/d H:i:s');
             $oPayment->Send['TotalAmount'] = (int) $oOrder->getGrandTotal();
             $oPayment->Send['TradeDesc'] = "AllPay_Magento_Module";
             $oPayment->Send['ChoosePayment'] = PaymentMethod::Alipay;
             $oPayment->Send['Remark'] = '';
             $oPayment->Send['ChooseSubPayment'] = PaymentMethodItem::None;
             $oPayment->Send['NeedExtraPaidInfo'] = ExtraPaymentInfo::No;
             $oPayment->Send['DeviceSource'] = DeviceType::PC;
             array_push($oPayment->Send['Items'], array('Name' => Mage::helper('alipay')->__('Commodity Group'), 'Price' => (int) $oOrder->getGrandTotal(), 'Currency' => Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(), 'Quantity' => 1, 'URL' => ''));
             $oPayment->SendExtend['Email'] = $oBilling->getEmail();
             $oPayment->SendExtend['PhoneNo'] = $oBilling->getTelephone();
             $oPayment->SendExtend['UserName'] = $oBilling->getName();
             $szHtml = $oPayment->CheckOutString();
         } catch (Exception $e) {
             Mage::throwException($e->getMessage());
         }
     }
     return $szHtml;
 }
 public function __construct()
 {
     $this->_config = new Google_Client();
     $this->_config->setClientId(Mage::helper('sociallogin')->getGoConsumerKey());
     $this->_config->setClientSecret(Mage::helper('sociallogin')->getGoConsumerSecret());
     $this->_config->setRedirectUri(Mage::getUrl('sociallogin/gologin/user'));
 }
Example #13
0
 public function offpayOption($observer)
 {
     $order = $observer->getEvent()->getOrder();
     if ($_REQUEST['payment']['method'] == 'offlinepay') {
         $order->setData('offpaytype', $_REQUEST['payment']['offtype']);
         if ($_REQUEST['payment']['offtype'] == 1) {
             $storeId = $order->getStore()->getId();
             $data = $order->getData();
             if (!Mage::helper('sales')->canSendNewOrderEmail($storeId)) {
                 return $order;
             }
             // Get the destination email addresses to send copies to
             $copyTo = $order->_getEmails(self::XML_PATH_EMAIL_COPY_TO);
             $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId);
             // Start store emulation process
             $appEmulation = Mage::getSingleton('core/app_emulation');
             $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
             try {
                 // Retrieve specified view block from appropriate design package (depends on emulated store)
                 $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())->setIsSecureMode(true);
                 $paymentBlock->getMethod()->setStore($storeId);
                 $paymentBlockHtml = $paymentBlock->toHtml();
             } catch (Exception $exception) {
                 // Stop store emulation process
                 $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
                 throw $exception;
             }
             // Stop store emulation process
             $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
             $customerName = $order->getCustomerName();
             $mailer = Mage::getModel('core/email_template_mailer');
             $emailInfo = Mage::getModel('core/email_info');
             $emailInfo->addTo($order->getCustomerEmail(), $customerName);
             if ($copyTo && $copyMethod == 'bcc') {
                 // Add bcc to customer email
                 foreach ($copyTo as $email) {
                     $emailInfo->addBcc($email);
                 }
             }
             $mailer->addEmailInfo($emailInfo);
             // Email copies are sent as separated emails if their copy method is 'copy'
             if ($copyTo && $copyMethod == 'copy') {
                 foreach ($copyTo as $email) {
                     $emailInfo = Mage::getModel('core/email_info');
                     $emailInfo->addTo($email);
                     $mailer->addEmailInfo($emailInfo);
                 }
             }
             $templateId = 22;
             // Set all required params and send emails
             $mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
             $mailer->setStoreId($storeId);
             $mailer->setTemplateId($templateId);
             $mailer->setTemplateParams(array('order' => $order, 'billing' => $order->getBillingAddress(), 'payment_html' => $paymentBlockHtml, 'paypalurl' => Mage::getUrl('offlinepay/redirect/index', array('orderid' => $data['increment_id']))));
             $mailer->send();
             $order->setEmailSent(true);
             $order->_getResource()->saveAttribute($order, 'email_sent');
         }
     }
 }
 public function indexAction()
 {
     //validate if ajax request
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         //redirect request if not login, this will not work if the ajax is requested
         if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
             $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array("PLEASE LOGIN!")));
         }
         //declare the store_id and customer_id
         $customer_id = Mage::getSingleton('customer/session')->getId();
         $store_id = Mage::app()->getStore()->getStoreId();
         //popup content
         $model = Mage::getModel("singpost_login/profile");
         $data = $model->getNotification();
         //check if close forever
         $notif_logs = $model->getNotificationLogs($customer_id);
         //check login count
         $login_count = $model->getUserLogCount($customer_id, $store_id);
         //insert to array and response as json
         $array = array('content' => stripcslashes($data[0]['content']), 'event' => $notif_logs, 'login_count' => $login_count['count']);
         $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($array));
     } else {
         //url request send back to the redirect
         Mage::app()->getResponse()->setRedirect(Mage::getUrl('customer/account/login'));
     }
 }
Example #15
0
 protected function _toHtml()
 {
     //store id is store view id
     $storeId = $this->_getStoreId();
     $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
     //customer group id
     $custGroup = $this->_getCustomerGroupId();
     $newurl = Mage::getUrl('rss/catalog/salesrule');
     $title = Mage::helper('rss')->__('%s - Discounts and Coupons', Mage::app()->getStore($storeId)->getName());
     $lang = Mage::getStoreConfig('general/locale/code');
     $rssObj = Mage::getModel('rss/rss');
     $data = array('title' => $title, 'description' => $title, 'link' => $newurl, 'charset' => 'UTF-8', 'language' => $lang);
     $rssObj->_addHeader($data);
     $now = date('Y-m-d');
     $_saleRule = Mage::getModel('salesrule/rule');
     $collection = $_saleRule->getResourceCollection()->addFieldToFilter('from_date', array('date' => true, 'to' => $now))->addFieldToFilter('website_ids', array('finset' => $websiteId))->addFieldToFilter('customer_group_ids', array('finset' => $custGroup))->addFieldToFilter('is_rss', 1)->addFieldToFilter('is_active', 1)->setOrder('from_date', 'desc');
     $collection->getSelect()->where('to_date is null or to_date>=?', $now);
     $collection->load();
     $url = Mage::getUrl('');
     foreach ($collection as $sr) {
         $description = '<table><tr>' . '<td style="text-decoration:none;">' . $sr->getDescription() . '<br/>Discount Start Date: ' . $this->formatDate($sr->getFromDate(), 'medium') . ($sr->getToDate() ? '<br/>Discount End Date: ' . $this->formatDate($sr->getToDate(), 'medium') : '') . ($sr->getCouponCode() ? '<br/> Coupon Code: ' . $sr->getCouponCode() . '' : '') . '</td>' . '</tr></table>';
         $data = array('title' => $sr->getName(), 'description' => $description, 'link' => $url);
         $rssObj->_addEntry($data);
     }
     return $rssObj->createRssXml();
 }
 /**
  * get the url to the voucher list page
  * @access public
  * @return string
  * @author Ultimate Module Creator
  */
 public function getVouchersUrl()
 {
     if ($listKey = Mage::getStoreConfig('instapago_voucher/voucher/url_rewrite_list')) {
         return Mage::getUrl('', array('_direct' => $listKey));
     }
     return Mage::getUrl('instapago_voucher/voucher/index');
 }
Example #17
0
 public function onControllerActionPredispatch($observer)
 {
     if ($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_index') {
         $hlr = Mage::helper("amscheckout");
         if ($hlr->isShoppingCartOnCheckout()) {
             $quote = $this->_getOnepage()->getQuote();
             if (!$quote->hasItems() || $quote->getHasError() || !$quote->validateMinimumAmount()) {
                 return;
             } else {
                 // Compose array of messages to add
                 $messages = array();
                 foreach ($this->_getOnepage()->getQuote()->getMessages() as $message) {
                     if ($message) {
                         // Escape HTML entities in quote message to prevent XSS
                         $message->setCode(Mage::helper('core')->escapeHtml($message->getCode()));
                         $messages[] = $message;
                     }
                 }
                 $this->getCustomerSession()->addUniqueMessages($messages);
                 foreach (Mage::getSingleton('checkout/session')->getMessages()->getItems() as $message) {
                     $this->getCustomerSession()->addMessage($message);
                 }
                 $url = Mage::getUrl('checkout/onepage', array('_secure' => true));
                 Mage::app()->getFrontController()->getResponse()->setRedirect($url)->sendResponse();
             }
         }
     } else {
         if ($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_onepage_index') {
             Mage::getModel("amscheckout/cart")->initAmscheckout();
         }
     }
 }
Example #18
0
 /**
  * Rewritten function of the standard controller. Tries to match the pathinfo on url parameters.
  *
  * @see Mage_Core_Controller_Varien_Router_Standard::match()
  * @param Zend_Controller_Request_Http $request The http request object that needs to be mapped on Action Controllers.
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $identifier = urldecode(trim($request->getPathInfo(), '/'));
     // try to gather url parameters from parser.
     $parser = Mage::getModel('seofilter/parser');
     $parsedRequestInfo = $parser->parseFilterInformationFromRequest($identifier, Mage::app()->getStore()->getId());
     if (!$parsedRequestInfo) {
         return false;
     }
     // if successfully gained url parameters, use them and dispatch ActionController action
     $request->setRouteName('catalog')->setModuleName('catalog')->setControllerName('category')->setActionName('view')->setParam('id', $parsedRequestInfo['categoryId']);
     $pathInfo = 'catalog/category/view/id/' . $parsedRequestInfo['categoryId'];
     $requestUri = '/' . $pathInfo . '?';
     foreach ($parsedRequestInfo['additionalParams'] as $paramKey => $paramValue) {
         //@dva fix
         if (is_array($paramValue)) {
             $paramValue = implode($paramValue, '_');
         }
         $requestUri .= $paramKey . '=' . $paramValue . '&';
     }
     $controllerClassName = $this->_validateControllerClassName('Mage_Catalog', 'category');
     $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $this->getFront()->getResponse());
     $request->setRequestUri(substr($requestUri, 0, -1));
     $request->setPathInfo($pathInfo);
     // dispatch action
     $request->setDispatched(true);
     $controllerInstance->dispatch('view');
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return true;
 }
Example #19
0
 /**
  * Render RSS
  *
  * @return string
  */
 protected function _toHtml()
 {
     $newUrl = Mage::getUrl('rss/catalog/notifystock');
     /* @var $helper Mage_Rss_Helper_Data */
     $helper = Mage::helper('Mage_Rss_Helper_Data');
     $title = $helper->__('Low Stock Products');
     $rssObj = Mage::getModel('Mage_Rss_Model_Rss');
     $data = array('title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8');
     $rssObj->_addHeader($data);
     $configManageStock = (int) Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
     $globalNotifyStockQty = (double) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY);
     $helper->disableFlat();
     /* @var $product Mage_Catalog_Model_Product */
     $product = Mage::getModel('Mage_Catalog_Model_Product');
     /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
     $collection = $product->getCollection();
     $stockItemTable = $collection->getTable('cataloginventory_stock_item');
     $stockItemWhere = '({{table}}.low_stock_date is not null) ' . " AND ( ({{table}}.use_config_manage_stock=1 AND {$configManageStock}=1)" . " AND {{table}}.qty < " . "IF({$stockItemTable}.`use_config_notify_stock_qty`, {$globalNotifyStockQty}, {{table}}.notify_stock_qty)" . ' OR ({{table}}.use_config_manage_stock=0 AND {{table}}.manage_stock=1) )';
     $collection->addAttributeToSelect('name', true)->joinTable('cataloginventory_stock_item', 'product_id=entity_id', array('qty' => 'qty', 'notify_stock_qty' => 'notify_stock_qty', 'use_config' => 'use_config_notify_stock_qty', 'low_stock_date' => 'low_stock_date'), $stockItemWhere, 'inner')->setOrder('low_stock_date');
     $collection->addAttributeToFilter('status', array('in' => Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getVisibleStatusIds()));
     Mage::dispatchEvent('rss_catalog_notify_stock_collection_select', array('collection' => $collection));
     /*
     using resource iterator to load the data one by one
     instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
     */
     Mage::getSingleton('Mage_Core_Model_Resource_Iterator')->walk($collection->getSelect(), array(array($this, 'addNotifyItemXmlCallback')), array('rssObj' => $rssObj, 'product' => $product, 'globalQty' => $globalNotifyStockQty));
     return $rssObj->createRssXml();
 }
 /**
  * Change standard OnePage checkout with One Click Order checkout
  * @param Varien_Event_Observer $observer
  * @return Smasoft_Oneclickorder_Model_Observer
  */
 public function changeOnepageCheckout(Varien_Event_Observer $observer)
 {
     switch ($observer->getEvent()->getName()) {
         case 'controller_action_layout_generate_blocks_after':
             /** @var $action Mage_Core_Controller_Varien_Action */
             $action = $observer->getEvent()->getAction();
             /** @var $layout Mage_Core_Model_Layout */
             $layout = $observer->getEvent()->getLayout();
             if ($action->getFullActionName() == 'checkout_cart_index' && $this->_helper()->isEnabled() && $this->_helper()->isChangeOnepageCheckout()) {
                 $block = $layout->getBlock('checkout.cart.methods');
                 if ($block && $block instanceof Mage_Core_Block_Abstract) {
                     $block->unsetChild('checkout.cart.methods.onepage');
                 }
                 $block = $layout->getBlock('checkout.cart.top_methods');
                 if ($block && $block instanceof Mage_Core_Block_Abstract) {
                     $block->unsetChild('checkout.cart.methods.onepage');
                 }
             }
             break;
         case 'controller_action_predispatch_checkout_onepage_index':
             if ($this->_helper()->isEnabled() && $this->_helper()->isChangeOnepageCheckout()) {
                 /** @var $action Mage_Core_Controller_Varien_Action */
                 $action = $observer->getEvent()->getControllerAction();
                 if ($action) {
                     $action->getResponse()->setRedirect(Mage::getUrl('checkout/cart/index'));
                 }
             }
             break;
     }
     return $this;
 }
 public function indexAction()
 {
     if (!Mage::helper('easycheckout')->getEasycheckoutConfig('general/active')) {
         $this->_redirect('checkout/onepage');
         return;
     }
     Mage::getSingleton('checkout/session')->setRBR(true);
     $quote = $this->getOnepage()->getQuote();
     if (!$quote->hasItems() || $quote->getHasError()) {
         $this->_redirect('checkout/cart');
         return;
     }
     if (!$quote->validateMinimumAmount()) {
         $error = Mage::getStoreConfig('sales/minimum_order/error_message');
         Mage::getSingleton('checkout/session')->addError($error);
         $this->_redirect('checkout/cart');
         return;
     }
     if (!count(Mage::getSingleton('customer/session')->getCustomer()->getAddresses())) {
         $this->setDefaultCountryId();
     }
     $this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
     Mage::getSingleton('checkout/session')->setCartWasUpdated(false);
     Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_secure' => true)));
     $this->getOnepage()->initCheckout();
     if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
         $this->getOnepage()->saveCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST);
     }
     $this->loadLayout();
     $this->_initLayoutMessages('customer/session');
     $this->getLayout()->getBlock('head')->setTitle(Mage::helper('easycheckout')->getEasycheckoutTitle());
     $this->renderLayout();
 }
Example #22
0
 /**
  * Validate and Match Manufacturer Page and modify request
  *
  * @param Zend_Controller_Request_Http $request
  * @return bool
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $router = 'manufacturers';
     $identifier = trim(str_replace('/manufacturers/', '', $request->getPathInfo()), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('manufacturer_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $manufacturer = Mage::getModel('zeon_manufacturer/manufacturer');
     $manufacturerId = $manufacturer->checkIdentifier($identifier, Mage::app()->getStore()->getId());
     if (trim($identifier) && $manufacturerId) {
         $request->setModuleName('manufacturers')->setControllerName('index')->setActionName('view')->setParam('manufacturer_id', $manufacturerId);
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $router . '/' . $identifier);
         return true;
     }
     return false;
 }
 public function _afterCreditmemoSave(Varien_Event_Observer $event)
 {
     $base_path = Mage::getBaseDir('base');
     $orgin_string = str_replace(PHP_EOL, '', file_get_contents($base_path . "/app/code/local/Nextorder/Refundbanking/Helper/sepaCheck.txt"));
     if ($orgin_string == 0) {
         return true;
     } else {
         $incrementCreditID = $event->getEvent()->getDataObject()->getCreditmemo()->getIncrementId();
         if (file_exists($base_path . "/media/Sepa_Gutschrift/" . $incrementCreditID . ".xml")) {
             //            Mage::log( "it works!!!!!!!!!!!: test ", null, 'xulin.log');
             return true;
         } else {
             $adminUser = Mage::getSingleton('admin/session')->getUser()->getUsername();
             //        $order = $event->getEvent()->getOrder();
             $Grand_Total = $event->getEvent()->getDataObject()->getCreditmemo()->getData('grand_total');
             //        $Base_Total = $event->getEvent()->getDataObject()->getCreditmemo()->getData('base_grand_total');
             //        Mage::log($event->getEvent()->getDataObject()->getCreditmemo()->getData() , null, 'xulin.log');
             $helper = Mage::helper("refundbanking/data");
             $orderNr = $event->getEvent()->getDataObject()->getCreditmemo()->getData('order_id');
             $order = Mage::getModel('sales/order')->load($orderNr);
             $payment_code = $order->getPayment()->getMethodInstance()->getCode();
             $paymentPools = array('ops_cc', 'paypal_billing_agreement', 'paypal_express');
             //        Mage::log( "it works +1", null, 'xulin.log');
             if ($helper->isConfig($payment_code)) {
                 $kontoInfos_shop = $helper->getKontonForRefund($payment_code);
                 $customer = Mage::getModel('customer/customer')->load($order->getData('customer_id'));
                 $urlForXML = $helper->getSepaXML($customer->getData('debit_payment_acount_name'), $customer->getId(), $customer->getData('debit_payment_account_iban'), $customer->getData('debit_payment_account_swift'), $kontoInfos_shop['inhaber'], $kontoInfos_shop['iban'], $kontoInfos_shop['bic'], $order->getIncrementId(), $incrementCreditID, $Grand_Total);
                 Mage::getSingleton('adminhtml/session')->addSuccess("Sepa XML Gutschrit ist von User " . $adminUser . " erstellt.<a href='" . str_replace('index.php/', '', Mage::getUrl()) . "media/Sepa_Gutschrift/" . $incrementCreditID . ".xml' download> Zum Download </a>");
                 $event->getEvent()->getDataObject()->getCreditmemo()->addComment("Sepa XML Gutschrit ist von User " . $adminUser . " erstellt.<a href='" . str_replace('index.php/', '', Mage::getUrl()) . "media/Sepa_Gutschrift/" . $incrementCreditID . ".xml' download> Zum Download </a>", true, true);
             }
         }
     }
 }
 public function viewAction()
 {
     $dealId = $this->getRequest()->getParam('id', 0);
     $deal = Mage::getModel('deal/deal')->setStoreId(Mage::app()->getStore()->getId())->load($dealId);
     if (!$deal->getId()) {
         $this->_forward('no-route');
     } elseif (!$deal->getStatus()) {
         $this->_forward('no-route');
     } else {
         Mage::register('current_deal_deal', $deal);
         $this->loadLayout();
         if ($root = $this->getLayout()->getBlock('root')) {
             $root->addBodyClass('deal-deal deal-deal' . $deal->getId());
         }
         if (Mage::helper('deal/deal')->getUseBreadcrumbs()) {
             if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')) {
                 $breadcrumbBlock->addCrumb('home', array('label' => Mage::helper('deal')->__('Home'), 'link' => Mage::getUrl()));
                 $breadcrumbBlock->addCrumb('deals', array('label' => Mage::helper('deal')->__('Deal'), 'link' => Mage::helper('deal')->getDealsUrl()));
                 $breadcrumbBlock->addCrumb('deal', array('label' => $deal->getName(), 'link' => ''));
             }
         }
         $headBlock = $this->getLayout()->getBlock('head');
         if ($headBlock) {
             if ($deal->getMetaTitle()) {
                 $headBlock->setTitle($deal->getMetaTitle());
             } else {
                 $headBlock->setTitle($deal->getName());
             }
             $headBlock->setKeywords($deal->getMetaKeywords());
             $headBlock->setDescription($deal->getMetaDescription());
         }
         $this->renderLayout();
     }
 }
Example #25
0
 /**
  * Generate RSS XML with sales rules data
  *
  * @return string
  */
 protected function _toHtml()
 {
     $storeId = $this->_getStoreId();
     $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
     $customerGroup = $this->_getCustomerGroupId();
     $now = date('Y-m-d');
     $url = Mage::getUrl('');
     $newUrl = Mage::getUrl('rss/catalog/salesrule');
     $lang = Mage::getStoreConfig('general/locale/code');
     $title = Mage::helper('rss')->__('%s - Discounts and Coupons', Mage::app()->getStore($storeId)->getName());
     /** @var $rssObject Mage_Rss_Model_Rss */
     $rssObject = Mage::getModel('rss/rss');
     /** @var $collection Mage_SalesRule_Model_Resource_Rule_Collection */
     $collection = Mage::getModel('salesrule/rule')->getResourceCollection();
     $data = array('title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8', 'language' => $lang);
     $rssObject->_addHeader($data);
     $collection->addWebsiteGroupDateFilter($websiteId, $customerGroup, $now)->addFieldToFilter('is_rss', 1)->setOrder('from_date', 'desc');
     $collection->load();
     foreach ($collection as $sr) {
         $description = '<table><tr>' . '<td style="text-decoration:none;">' . $sr->getDescription() . '<br/>Discount Start Date: ' . $this->formatDate($sr->getFromDate(), 'medium') . ($sr->getToDate() ? '<br/>Discount End Date: ' . $this->formatDate($sr->getToDate(), 'medium') : '') . ($sr->getCouponCode() ? '<br/> Coupon Code: ' . $this->escapeHtml($sr->getCouponCode()) . '' : '') . '</td>' . '</tr></table>';
         $data = array('title' => $sr->getName(), 'description' => $description, 'link' => $url);
         $rssObject->_addEntry($data);
     }
     return $rssObject->createRssXml();
 }
Example #26
0
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('magicproduct_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     if (!in_array($identifier, $this->router)) {
         return false;
     }
     $request->setModuleName('magicproduct')->setControllerName('index')->setActionName('product')->setParam('type', $identifier);
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return true;
 }
Example #27
0
 public function getStandardCheckoutFormFields()
 {
     $order = $this->getOrder();
     if (!$order instanceof Mage_Sales_Model_Order) {
         Mage::throwException($this->_getHelper()->__('Cannot retrieve order object'));
     }
     $billingAddress = $order->getBillingAddress();
     $shippingAddress = $order->getShippingAddress();
     $streets = $billingAddress->getStreet();
     $street = isset($streets[0]) && $streets[0] != '' ? $streets[0] : (isset($streets[1]) && $streets[1] != '' ? $streets[1] : '');
     if ($this->getConfig()->getDescription()) {
         $transDescription = $this->getConfig()->getDescription();
     } else {
         $transDescription = Mage::helper('Avenues')->__('Order #%s', $order->getRealOrderId());
     }
     if ($order->getCustomerEmail()) {
         $email = $order->getCustomerEmail();
     } elseif ($billingAddress->getEmail()) {
         $email = $billingAddress->getEmail();
     } else {
         $email = '';
     }
     $fields = array('Merchant_Id' => $this->getConfig()->getAccountId(), 'WorkingKey' => $this->getConfigData('workingkey'), 'product_price' => $order->getBaseGrandTotal(), 'Redirect_Url' => Mage::getUrl('Avenues/standard/success', array('_secure' => true)), 'product_name' => $transDescription, 'language' => $this->getConfig()->getLanguage(), 'billing_cust_name' => $billingAddress->getFirstname() . ' ' . $billingAddress->getLastname(), 'billing_last_name' => $billingAddress->getLastname(), 'billing_cust_address' => $street, 'billing_cust_city' => $billingAddress->getCity(), 'billing_cust_state' => $billingAddress->getRegionCode(), 'billing_zip_code' => $billingAddress->getPostcode(), 'billing_cust_country' => $billingAddress->getCountryModel()->getName(), 'billing_cust_tel' => $billingAddress->getTelephone(), 'billing_cust_email' => $email, 'delivery_cust_name' => $shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname(), 'delivery_last_name' => $shippingAddress->getLastname(), 'delivery_cust_address' => $shippingAddress->getStreetFull(), 'delivery_cust_city' => $shippingAddress->getCity(), 'delivery_cust_state' => $shippingAddress->getRegionCode(), 'delivery_zip_code' => $shippingAddress->getPostcode(), 'delivery_cust_country' => $shippingAddress->getCountryModel()->getName(), 'delivery_cust_tel' => $shippingAddress->getTelephone(), 'cb_url' => $this->getNotificationURL(), 'cb_type' => 'P', 'decline_url' => $this->getFailureURL(), 'cs1' => $order->getRealOrderId(), 'Checksum' => getCheckSum($this->getConfig()->getAccountId(), $order->getBaseGrandTotal(), $order->getRealOrderId(), Mage::getUrl('Avenues/standard/success', array('_secure' => true)), $this->getConfigData('workingkey')));
     if ($this->getConfig()->getDebug()) {
         $debug = Mage::getModel('Avenues/api_debug')->setRequestBody($this->getAvenuesUrl() . "\n" . print_r($fields, 1))->save();
         $fields['cs2'] = $debug->getId();
     }
     return $fields;
 }
 /**
  *
  * @return Zend_Service_Akismet
  */
 protected function _getService()
 {
     if (null === $this->_service) {
         $this->_service = new Zend_Service_Akismet($this->_getApiKey(), Mage::getUrl('/'));
     }
     return $this->_service;
 }
 /**
  * Return back url for logged in and guest users
  *
  * @return string
  */
 public function getBackUrl()
 {
     if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
         return Mage::getUrl('/');
     }
     return $this->url('orders');
 }
Example #30
0
 /**
  * get the url to the deal details page
  * @access public
  * @return string
  * @author Ultimate Module Creator
  */
 public function getDealUrl()
 {
     if ($this->getUrlKey()) {
         return Mage::getUrl('', array('_direct' => $this->getUrlKey()));
     }
     return Mage::getUrl('deal/deal/view', array('id' => $this->getId()));
 }