Example #1
0
 protected function _exportAddressses($data)
 {
     $version = Mage::getVersionInfo();
     if ($version['major'] >= 1 && $version['minor'] >= 7) {
         parent::_exportAddressses($data);
     } else {
         $address = new Varien_Object();
         Varien_Object_Mapper::accumulateByMap($data, $address, $this->_billingAddressMap);
         $address->setExportedKeys(array_values($this->_billingAddressMap));
         $this->_applyStreetAndRegionWorkarounds($address);
         $this->setExportedBillingAddress($address);
         // assume there is shipping address if there is at least one field specific to shipping
         if (isset($data['SHIPTONAME'])) {
             $shippingAddress = clone $address;
             Varien_Object_Mapper::accumulateByMap($data, $shippingAddress, $this->_shippingAddressMap);
             $this->_applyStreetAndRegionWorkarounds($shippingAddress);
             // PayPal doesn't provide detailed shipping name fields, so the name will be overwritten
             $firstName = $data['SHIPTONAME'];
             $lastName = null;
             if (isset($data['FIRSTNAME']) && $data['LASTNAME']) {
                 $firstName = $data['FIRSTNAME'];
                 $lastName = $data['LASTNAME'];
             }
             $shippingAddress->addData(array('prefix' => null, 'firstname' => $firstName, 'middlename' => null, 'lastname' => $lastName, 'suffix' => null));
             $this->setExportedShippingAddress($shippingAddress);
         }
     }
 }
Example #2
0
 public function getCount($filter, $range)
 {
     $select = $this->_getSelect($filter);
     $connection = $this->_getReadAdapter();
     $response = $this->_dispatchPreparePriceEvent($filter, $select);
     //$table      = $this->_getIndexTableAlias();
     $i = Mage::getVersionInfo();
     if ($i['minor'] < 7) {
         $table = 'price_index';
     } else {
         $table = 'e';
     }
     $additional = str_replace('price_index.', 'e.', join('', $response->getAdditionalCalculations()));
     $rate = $filter->getCurrencyRate();
     $countExpr = new Zend_Db_Expr('COUNT(*)');
     $rangeExpr = new Zend_Db_Expr("FLOOR((({$table}.min_price {$additional}) * {$rate}) / {$range}) + 1");
     if (($customer = Mage::getModel('customer/session')->getCustomer()) && $customer->getId()) {
         $from = $select->getPart('from');
         $tablePrefix = (string) Mage::getConfig()->getTablePrefix();
         if (!in_array('cp_prices', array_keys($from))) {
             $select->joinLeft(array('cp_prices' => $tablePrefix . 'customerprices_prices'), 'cp_prices.product_id=e.entity_id AND cp_prices.customer_id=' . $customer->getId() . ' and qty = 1', array());
         }
         $col = "IF(cp_prices.special_price > 0, cp_prices.special_price,IF(cp_prices.price > 0,cp_prices.price,IF({$table}.final_price IS NULL, {$table}.min_price,{$table}.final_price)))";
         //$col = "IF(cp_prices.special_price > 0, cp_prices.special_price,IF(cp_prices.price > 0,cp_prices.price,IF(price_index.final_price > 0, price_index.final_price,price_index.min_price)))";
         //$col = "IF(cp_prices.special_price > 0, cp_prices.special_price,IF(cp_prices.price > 0,cp_prices.price,price_index.final_price))";
         $rangeExpr = new Zend_Db_Expr("FLOOR((({$col} {$additional}) * {$rate}) / {$range}) + 1");
     }
     $select->columns(array('range' => $rangeExpr, 'count' => $countExpr));
     $select->group('range');
     return $connection->fetchPairs($select);
 }
Example #3
0
 /**
  * Gathers all of the sales rules on the system
  *
  * @return array
  */
 protected function _fillOptions($default = false)
 {
     $options = array();
     /** @var Mage_SalesRule_Model_Resource_Rule_Collection $rules */
     $now = Mage::getModel('core/date')->date('Y-m-d');
     $rules = Mage::getModel('salesrule/rule')->getCollection()->addFieldToFilter('is_active', array('eq' => 1))->addFieldToFilter('coupon_type', array('in' => array(Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC, Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO)))->addFieldToFilter('from_date', array(array('null' => true), array('lteq' => $now)))->addFieldToFilter('to_date', array(array('null' => true), array('gteq' => $now)))->setOrder('sort_order');
     if (!Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 6, 10, 11, array('major' => 9, 'edition' => 'Professional')))) {
         $rules->addFieldToFilter('use_auto_generation', array('eq' => 0));
     }
     // If there are any rules
     if ($rules->getSize()) {
         // Cycle Through Rules
         foreach ($rules as $rule) {
             // Handle Coupon Label
             $couponLabel = '(Coupon: *Auto Generated*)';
             if ($couponCode = $rule->getPrimaryCoupon()->getCode()) {
                 $couponLabel = "(Coupon: {$couponCode})";
             }
             // Build Option
             $options[] = array('label' => "{$rule->getName()} {$couponLabel}", 'value' => $rule->getRuleId());
         }
     }
     $noneSelected = '-- None Selected --';
     if ($default) {
         $noneSelected = '-- Use Default --';
     }
     // Add -- None Selected -- Option
     array_unshift($options, array('label' => Mage::helper('bronto_common')->__($noneSelected), 'value' => ''));
     return $options;
 }
Example #4
0
File: Api.php Project: nXqd/mapy
 /**
  * 
  * Retrieve the version of Magento.
  * @param string $asType Should be 'array' if we want the method to return array
  * @return mixed Either string or array (if the passed param is 'array')
  */
 public function currentVersion($asType = '')
 {
     if ($asType == 'array') {
         return Mage::getVersionInfo();
     }
     return Mage::getVersion();
 }
Example #5
0
 /**
  * Reset Roundtrip verification status, disable all modules, and unlink all Bronto Transactional Emails
  *
  * @param bool $includeCommon
  */
 protected function _disableAndUnlink($includeCommon = false)
 {
     $sentry = Mage::getModel('bronto_common/keysentry');
     $sentry->disableModules($this->getScope(), $this->getScopeId(), $includeCommon);
     if (!Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('edition' => 'Professional', 'major' => 9)))) {
         $sentry->unlinkEmails(Mage::getModel('bronto_email/message')->getCollection(), $this->getScope(), $this->getScopeId());
     }
 }
Example #6
0
 public function submitOrder()
 {
     $version = Mage::getVersionInfo();
     if (1 <= $version['major'] && 4 <= $version['minor'] && $version['revision'] <= 1) {
         return parent::submitOrder();
     }
     $this->_deleteNominalItems();
     $this->_validate();
     $quote = $this->_quote;
     $isVirtual = $quote->isVirtual();
     $transaction = Mage::getModel('core/resource_transaction');
     if ($quote->getCustomerId()) {
         $transaction->addObject($quote->getCustomer());
     }
     $transaction->addObject($quote);
     $quote->reserveOrderId();
     if ($isVirtual) {
         $order = $this->_convertor->addressToOrder($quote->getBillingAddress());
     } else {
         $order = $this->_convertor->addressToOrder($quote->getShippingAddress());
     }
     $order->setBillingAddress($this->_convertor->addressToOrderAddress($quote->getBillingAddress()));
     if (!$isVirtual) {
         $order->setShippingAddress($this->_convertor->addressToOrderAddress($quote->getShippingAddress()));
     }
     $order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment()));
     foreach ($this->_orderData as $key => $value) {
         $order->setData($key, $value);
     }
     foreach ($quote->getAllItems() as $item) {
         $orderItem = $this->_convertor->itemToOrderItem($item);
         if ($item->getParentItem()) {
             $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
         }
         // elite paint
         $this->setItemPaint($orderItem, $item);
         $order->addItem($orderItem);
     }
     $transaction->addObject($order);
     $transaction->addCommitCallback(array($order, 'place'));
     $transaction->addCommitCallback(array($order, 'save'));
     /**
      * We can use configuration data for declare new order status
      */
     Mage::dispatchEvent('checkout_type_onepage_save_order', array('order' => $order, 'quote' => $quote));
     Mage::dispatchEvent('sales_model_service_quote_submit_before', array('order' => $order, 'quote' => $quote));
     try {
         $transaction->save();
         $this->_inactivateQuote();
         Mage::dispatchEvent('sales_model_service_quote_submit_success', array('order' => $order, 'quote' => $quote));
     } catch (Exception $e) {
         Mage::dispatchEvent('sales_model_service_quote_submit_failure', array('order' => $order, 'quote' => $quote));
         throw $e;
     }
     Mage::dispatchEvent('sales_model_service_quote_submit_after', array('order' => $order, 'quote' => $quote));
     $this->_order = $order;
     return $order;
 }
Example #7
0
 public function _construct()
 {
     parent::_construct();
     $this->_templateTable = $this->getResource()->getTable('bronto_email/template');
     $this->_brontoTable = $this->getResource()->getTable('bronto_email/message');
     if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, array('edition' => 'Professional', 'major' => 9)))) {
         $this->_select->joinLeft(array($this->_brontoTable), "`{$this->_templateTable}`.`template_id` = `{$this->_brontoTable}`.`core_template_id`");
     }
 }
Example #8
0
 /**
  * Test if this is an older magento
  *
  * @return boolean
  */
 public function isOldMagento()
 {
     $isEE = Mage::helper('core')->isModuleEnabled('Enterprise_Enterprise');
     $magentoVersion = Mage::getVersionInfo();
     if ($magentoVersion['minor'] < 9 || $isEE && $magentoVersion['minor'] < 13) {
         return true;
     }
     return false;
 }
Example #9
0
 public function aboveVersion($version)
 {
     $info = Mage::getVersionInfo();
     //Enterprise 1.10 is equivalent to Community 1.4
     if ($info['major'] == 1 && $info['minor'] == 10) {
         $info['minor'] = 4;
     }
     $version = explode('.', $version);
     return intval($info['major']) >= intval($version[0]) && intval($info['minor']) >= intval($version[1]);
 }
 public function versionIsAtLeast16()
 {
     $versionInfo = Mage::getVersionInfo();
     if ($versionInfo['major'] >= 1) {
         if ($versionInfo['minor'] >= 6) {
             return true;
         }
     }
     return false;
 }
 /**
  * Is patch requried for 1.5?
  *
  * @return string
  */
 public function isPaymentPatchRequired()
 {
     $version = Mage::getVersionInfo();
     if ($version['major'] == '1' && $version['minor'] == '5') {
         $payment = Mage::getSingleton('sales/order_payment');
         if (!method_exists($payment, 'lookupTransaction')) {
             return true;
         }
         return false;
     }
 }
 /**
  * Initialize layout.
  *
  * @return Mage_ImportExport_Adminhtml_ExportController
  */
 protected function _initAction()
 {
     $this->_title($this->__('Import/Export'))->loadLayout()->_setActiveMenu('system/importexport');
     // add support of Magento CE 1.6
     $version_info = Mage::getVersionInfo();
     if ($version_info['major'] == 1 && $version_info['minor'] < 7 && !method_exists('Mage', 'getEdition')) {
         $head = $this->getLayout()->getBlock('head');
         $head->addItem('js_css', 'prototype/windows/themes/magento.css');
         $head->removeItem('skin_css', 'lib/prototype/windows/themes/magento.css');
     }
     return $this;
 }
Example #13
0
 /**
  * Generate list of email templates
  *
  * @return array
  */
 public function toOptionArray()
 {
     // If Collection isn't already in registry, create it
     if (!($collection = Mage::registry('config_system_email_template'))) {
         // Define Tables
         $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
         $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
         // Load Collection
         $collection = Mage::getModel('bronto_email/template')->getCollection();
         // Apply conditional logic to handle 1.9 overriding collection _construct
         if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, array('edition' => 'Professional', 'major' => 9), 10))) {
             $collection->getSelect()->joinLeft($brontoTable, "{$templateTable}.template_id = {$brontoTable}.core_template_id");
         }
         // If module is enabled
         if (Mage::helper('bronto_email')->isEnabled()) {
             // If Store Scope
             if (Mage::app()->getRequest()->getParam('store')) {
                 // if Store ID Specified, filter collection
                 if ($storeCode = Mage::app()->getRequest()->getParam('store')) {
                     $store = Mage::app()->getStore($storeCode);
                     $storeId = $store->getId();
                     $collection->addStoreViewFilter($storeId);
                 }
             }
             // Add Where statement to prevent loading templates without core_template_id
             $collection->getSelect()->where("{$brontoTable}.core_template_id IS NOT NULL");
         }
         $collection->addOrder('template_code', 'asc')->load();
         Mage::register('config_system_email_template', $collection);
     }
     // Get Array of Template Options
     $options = $collection->toOptionArray();
     // Set up Default Template Name
     $templateName = Mage::helper('adminhtml')->__('Default Template from Locale');
     // Add support for Template configuration page
     $pathParts = explode('/', $this->getPath());
     if ('bronto_email' == $pathParts[0] && 'templates' == $pathParts[1]) {
         $path = str_replace('-', '/', array_pop($pathParts));
     } else {
         $path = $this->getPath();
     }
     // Add a 'Do Not Send' option
     array_unshift($options, array('value' => 'nosend', 'label' => 'Do Not Send'));
     $nodeName = str_replace('/', '_', $path);
     $templateLabelNode = Mage::app()->getConfig()->getNode(self::XML_PATH_TEMPLATE_EMAIL . $nodeName . '/label');
     if ($templateLabelNode) {
         $templateName = Mage::helper('adminhtml')->__((string) $templateLabelNode);
         $templateName = Mage::helper('adminhtml')->__('%s (Default Template from Locale)', $templateName);
     }
     array_unshift($options, array('value' => $nodeName, 'label' => $templateName));
     return $options;
 }
Example #14
0
 /**
  * Watches for the enable switch to change to disable
  *
  * event: bronto_disable
  *
  * @param Varien_Event_Observer $observer
  */
 public function watchDisableAction(Varien_Event_Observer $observer)
 {
     // Get Scope
     $scopeParams = Mage::helper('bronto_common')->getScopeParams();
     $scope = $scopeParams['scope'];
     $scopeId = $scopeParams[$scopeParams['scope'] . '_id'];
     // Get Sentry and Disable Modules
     $sentry = Mage::getModel('bronto_common/keysentry');
     $sentry->disableModules($scope, $scopeId, true);
     // Unlink all Emails
     if (!Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('edition' => 'Professional', 'major' => 9)))) {
         $sentry->unlinkEmails(Mage::getModel('bronto_email/message')->getCollection(), $scope, $scopeId);
     }
 }
Example #15
0
 protected function _prepareCollection()
 {
     /* @var $collection Bronto_Email_Model_Mysql4_Template_Collection */
     $collection = Mage::getModel('bronto_email/template')->getCollection();
     $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
     $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
     // Apply conditional logic to handle 1.9 overriding collection _construct
     if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, array('edition' => 'Professional', 'major' => 9), 10))) {
         $collection->getSelect()->joinLeft($brontoTable, "{$templateTable}.template_id = {$brontoTable}.core_template_id");
     }
     // Limit grid to show only those templates without message id assigned
     $collection->addFieldToFilter("{$brontoTable}.bronto_message_id", array('null' => true));
     $this->setCollection($collection);
     return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
 }
Example #16
0
 /**
  * Perform actions after object load
  *
  * @return Bronto_Reminder_Model_Rule
  */
 protected function _afterLoad()
 {
     Mage_Core_Model_Abstract::_afterLoad();
     if (Mage::helper('bronto_verify')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('<=', 6), array('edition' => 'Professional', 'major' => 9), 10, 11))) {
         $conditionsArr = unserialize($this->getConditionsSerialized());
         if (!empty($conditionsArr) && is_array($conditionsArr)) {
             $this->getConditions()->loadArray($conditionsArr);
         }
     }
     $messageData = $this->_getResource()->getMessageData($this->getId());
     foreach ($messageData as $data) {
         $message = empty($data['message_id']) ? null : $data['message_id'];
         $sendType = empty($data['send_type']) ? 'transactional' : $data['send_type'];
         $this->setData('store_message_' . $data['store_id'], $message)->setData('store_message_sendtype_' . $data['store_id'], $sendType)->setData('store_message_sendflags_' . $data['store_id'], $data['send_flags']);
     }
     return $this;
 }
Example #17
0
 public function isCurrentVersionMore($version)
 {
     if (is_null($this->_cacheVersion)) {
         $serverVer = Mage::getVersionInfo();
         $tmp = sprintf('%02s%02s%02s%02s', $serverVer['major'], $serverVer['minor'], $serverVer['revision'], $serverVer['patch']);
         $this->_cacheVersion = (int) $tmp;
     }
     $tmp = explode('.', $version);
     $version = '';
     for ($i = 0; $i < 4; $i++) {
         if (isset($tmp[$i])) {
             $version .= sprintf('%02s', $tmp[$i]);
         } else {
             $version .= '00';
         }
     }
     return $this->_cacheVersion >= $version ? true : false;
 }
Example #18
0
 /**
  * Return footer html for fieldset
  * Add extra tooltip comments to elements
  *
  * @param Varien_Data_Form_Element_Abstract $element
  *
  * @return string
  */
 protected function _getFooterHtml($element)
 {
     $owner = Mage::getStoreConfig('bronto_verify/permissionchecker/owner');
     $group = Mage::getStoreConfig('bronto_verify/permissionchecker/group');
     $dir = Mage::getStoreConfig('bronto_verify/permissionchecker/directories');
     $file = Mage::getStoreConfig('bronto_verify/permissionchecker/files');
     if ('' != $owner || '' != $group) {
         $chown = 'sudo chown -R ' . ('' != $owner ? $owner : '') . ('' != $group ? ':' . $group : '') . ' ./*';
     } else {
         $chown = '';
     }
     $vMage = 'mage';
     if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('<', 5)))) {
         $vMage = 'pear';
     }
     $dPerm = '' == $dir ? '755' : $dir;
     $fPerm = '' == $file ? '644' : $file;
     $html = "<tr><td>&nbsp;</td>\n            <td colspan=\"3\"><strong style=\"margin:5px;\">To apply permissions, Run These Commands in the shell at the root of your site:</strong>\n            <div style=\"border:1px solid #ccc; padding:5px; margin:5px;\">\n<pre>{$chown}\nsudo find . -type d -exec chmod {$dPerm} {} \\;\nsudo find . -type f -exec chmod {$fPerm} {} \\;\nsudo chmod -R 777 media\nsudo chmod -R 777 var\nsudo chmod 550 {$vMage}\nsudo chmod o+w var/.htaccess app/etc</pre>\n</div></td></tr>";
     return $html . parent::_getFooterHtml($element);
 }
 /**
  * Initialize the modal headers for products and message sending
  *
  * @return Bronto_Product_Adminhtml_RecommendationsController
  */
 protected function _modalStyles()
 {
     $head = $this->getLayout()->getBlock('head');
     $head->addItem('js_css', 'prototype/windows/themes/default.css');
     $enabled = Mage::getSingleton('cms/wysiwyg_config')->isEnabled();
     if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), '1', array('6', array('edition' => 'Professional', 'major' => '9'), '10', '11'))) {
         $head->addItem('js_css', 'prototype/windows/themes/magento.css');
         if ($enabled) {
             $head->addItem('js_css', 'mage/adminhtml/wysiwyg/tiny_mce/setup.js');
         }
     } else {
         $head->addCss('lib/prototype/windows/themes/magento.css');
         if ($enabled) {
             $head->addJs('mage/adminhtml/wysiwyg/tiny_mce/setup.js');
         }
     }
     if ($enabled) {
         $head->setCanLoadTinyMce(true);
     }
     return $this;
 }
Example #20
0
 public function getMagentoVersion()
 {
     $ver_info = Mage::getVersionInfo();
     $mag_version = "{$ver_info['major']}.{$ver_info['minor']}.{$ver_info['revision']}.{$ver_info['patch']}";
     return $mag_version;
 }
Example #21
0
 public function testIsApplicableToQuoteFeatureModelTrue()
 {
     $versionInfo = Mage::getVersionInfo();
     if (array_key_exists('minor', $versionInfo) && (Mage::getEdition() === Mage::EDITION_COMMUNITY && $versionInfo['minor'] > '7') || Mage::getEdition() === Mage::EDITION_ENTERPRISE && $versionInfo['minor'] > '13') {
         $featureModelMock = $this->getModelMock('ops/payment_features_zeroAmountAuth', array('isCCAndZeroAmountAuthAllowed'));
         $featureModelMock->expects($this->any())->method('isCCAndZeroAmountAuthAllowed')->will($this->returnValue(true));
         $this->replaceByMock('model', 'ops/payment_features_zeroAmountAuth', $featureModelMock);
         $helperMock = $this->getHelperMock('ops/version', array('canUseApplicableForQuote'));
         $helperMock->expects($this->any())->method('canUseApplicableForQuote')->will($this->returnValue(true));
         $this->replaceByMock('helper', 'ops/version', $helperMock);
         $quote = Mage::getModel('sales/quote');
         $this->assertTrue($this->_model->isApplicableToQuote($quote, '1'));
     }
 }
 public function saveOrder()
 {
     $info = Mage::getVersionInfo();
     $version = "{$info['major']}.{$info['minor']}.{$info['revision']}.{$info['patch']}";
     $this->validate();
     $newCustomer = false;
     if ($this->getCheckoutMethod() === self::REGISTER) {
         $this->_prepareNewCustomerQuote();
         $newCustomer = true;
     } else {
         $this->_prepareCustomerQuote();
     }
     $service_quote = Mage::getModel('checkoutsimplificado/service_quote', $this->getQuote());
     if ($version == '1.4.0.1') {
         $order = $service_quote->submit();
     } else {
         $order = $service_quote->submitAll();
         $order = $service_quote->getOrder();
     }
     if ($newCustomer) {
         try {
             $this->_involveNewCustomer();
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
     if ($version != '1.4.0.1') {
         $this->getCheckout()->setLastQuoteId($this->getQuote()->getId())->setLastSuccessQuoteId($this->getQuote()->getId())->clearHelperData();
     }
     if ($order) {
         Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order' => $order, 'quote' => $this->getQuote()));
         $r_url = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
         if (!$r_url) {
             try {
                 $order->sendNewOrderEmail();
             } catch (Exception $e) {
                 Mage::logException($e);
             }
         }
         if ($version == '1.4.0.1') {
             $this->getCheckout()->setLastQuoteId($this->getQuote()->getId())->setLastOrderId($order->getId())->setLastRealOrderId($order->getIncrementId())->setRedirectUrl($r_url)->setLastSuccessQuoteId($this->getQuote()->getId());
         } else {
             $this->getCheckout()->setLastOrderId($order->getId())->setRedirectUrl($r_url)->setLastRealOrderId($order->getIncrementId());
             $agree = $order->getPayment()->getBillingAgreement();
             if ($agree) {
                 $this->getCheckout()->setLastBillingAgreementId($agree->getId());
             }
         }
     }
     if ($version != '1.4.0.1') {
         $profiles = $service_quote->getRecurringPaymentProfiles();
         if ($profiles) {
             $ids = array();
             foreach ($profiles as $profile) {
                 $ids[] = $profile->getId();
             }
             $this->getCheckout()->setLastRecurringProfileIds($ids);
         }
     }
     return $this;
 }
Example #23
0
 public function getMagetoVersion()
 {
     $i = Mage::getVersionInfo();
     if ($i['major'] == 1 && $this->isMagetoEnterprise()) {
         $i['minor'] -= 5;
     }
     return trim("{$i['major']}.{$i['minor']}.{$i['revision']}" . ($i['patch'] != '' ? ".{$i['patch']}" : "") . "-{$i['stability']}{$i['number']}", '.-');
 }
Example #24
0
 public static function getAddonOptions($store = null)
 {
     $ret = array();
     $ret['parent_private_key'] = self::getParentPrivateKey();
     $ret['private_key'] = self::getPrivateKeys();
     $ret['api_key'] = self::getApiKeys();
     $ret['export_status'] = self::getExportStatuses();
     $ret['last_request'] = self::formatDate(self::getLastRequest(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
     $ret['last_resync'] = self::formatDate(self::getLastResync(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
     $ret['addon_status'] = self::getStatusModule() == 'Y' ? 'enabled' : 'disabled';
     $ret['addon_version'] = (string) Mage::getConfig()->getModuleConfig("Simtech_Searchanise")->version;
     $versionInfo = Mage::getVersionInfo();
     $coreEdition = 'Community';
     // [v1.7] [v1.8] [v1.9]
     if (method_exists('Mage', 'getEdition')) {
         $coreEdition = Mage::getEdition();
         // [/v1.7] [/v1.8] [/v1.9]
         // [v1.5] [v1.6]
     } elseif (isset($versionInfo['minor']) && $versionInfo['minor'] > 6) {
         $coreEdition = 'Enterprise';
     }
     // [/v1.5] [/v1.6]
     $ret['core_edition'] = $coreEdition;
     $ret['core_version'] = Mage::getVersion();
     $ret['core_version_info'] = $versionInfo;
     return $ret;
 }
 public function saveOrderAction()
 {
     //if (!$this->_validateFormKey()) {
     //$this->_redirect('*/*');
     //return;
     //}
     if ($this->_expireAjax()) {
         return;
     }
     $version = Mage::getVersionInfo();
     $result = array();
     try {
         $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
         if ($requiredAgreements) {
             $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
             $diff = array_diff($requiredAgreements, $postedAgreements);
             if ($diff) {
                 $result['error'] = $this->__('Please agree to all the terms and conditions before placing the order.');
                 $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
                 return;
             }
         }
         $data = $this->getRequest()->getPost('payment', array());
         if ($data) {
             /** Magento CE 1.8 version**/
             if ($version['minor'] == 8) {
                 $data['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;
             }
             $this->getOnepage()->getQuote()->getPayment()->importData($data);
         }
         // save comments
         if (Mage::helper('opc')->isShowComment()) {
             $comment = $this->getRequest()->getPost('customer_comment', '');
             if (empty($comment)) {
                 $comment = Mage::getSingleton('core/session')->getOpcOrderComment();
             } else {
                 Mage::getSingleton('core/session')->setOpcOrderComment($comment);
             }
             $this->getOnepage()->getQuote()->setCustomerNote($comment);
         }
         ///
         $this->getOnepage()->saveOrder();
         /** Magento CE 1.6 version**/
         if ($version['minor'] == 6) {
             $storeId = Mage::app()->getStore()->getId();
             $paymentHelper = Mage::helper("payment");
             $zeroSubTotalPaymentAction = $paymentHelper->getZeroSubTotalPaymentAutomaticInvoice($storeId);
             if ($paymentHelper->isZeroSubTotal($storeId) && $this->_getOrder()->getGrandTotal() == 0 && $zeroSubTotalPaymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE && $paymentHelper->getZeroSubTotalOrderStatus($storeId) == 'pending') {
                 $invoice = $this->_initInvoice();
                 $invoice->getOrder()->setIsInProcess(true);
                 $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
                 $transactionSave->save();
             }
         }
         $redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
     } catch (Mage_Payment_Model_Info_Exception $e) {
         $message = $e->getMessage();
         if (!empty($message)) {
             $result['error_messages'] = $message;
         }
         $result['payment'] = $this->_getPaymentMethodsHtml();
     } catch (Mage_Core_Exception $e) {
         Mage::logException($e);
         Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
         $result['error'] = $e->getMessage();
         $gotoSection = $this->getOnepage()->getCheckout()->getGotoSection();
         if ($gotoSection) {
             $this->getOnepage()->getCheckout()->setGotoSection(null);
         }
         $updateSection = $this->getOnepage()->getCheckout()->getUpdateSection();
         if ($updateSection) {
             $this->getOnepage()->getCheckout()->setUpdateSection(null);
         }
     } catch (Exception $e) {
         Mage::logException($e);
         Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
         $result['error'] = $this->__('There was an error processing your order. Please contact us or try again later.');
     }
     $this->getOnepage()->getQuote()->save();
     /**
      * when there is redirect to third party, we don't want to save order yet.
      * we will save the order in return action.
      */
     if (isset($redirectUrl) && !empty($redirectUrl)) {
         $result['redirect'] = $redirectUrl;
     } else {
         $result['redirect'] = Mage::getUrl('checkout/onepage/success', array('_secure' => true));
     }
     $this->getResponse()->setHeader('Content-type', 'application/json', true);
     $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
 }
Example #26
0
 protected function _isSessionRequired()
 {
     $version = Mage::getVersionInfo();
     if ($version['minor'] >= 8 && !isset($_COOKIE[$this->_sessionName])) {
         return true;
     } else {
         return false;
     }
 }
Example #27
0
 /**
  * Creates an admin user in the Magento backend.
  * 
  * If you pass no parameters, it attempts to use posix data to pre-fill the fields
  * and will prompt you to confirm.  You can also pass it the following parameters
  * in order and it will create a user without prompting.
  * 
  * admin-createadmin <username> <firstname> <lastname> <email> <password>
  * 
  * The password will be MD5-hashed for you when the user is created.
  * 
  * @param create user options
  * @author Nicholas Vahalik <*****@*****.**>
  */
 function createadminAction($options)
 {
     $defaults = $this->_prefillUserData($options);
     if (count($options) != 5) {
         do {
             printf('Login [%s]: ', $defaults['login']);
             $login = ($input = trim(fgets(STDIN))) != '' ? $input : $defaults['login'];
         } while ($login == '');
         do {
             printf('First name [%s]: ', $defaults['firstName']);
             $firstName = ($input = trim(fgets(STDIN))) != '' ? $input : $defaults['firstName'];
         } while ($firstName == '');
         do {
             printf('Last name [%s]: ', $defaults['lastName']);
             $lastName = ($input = trim(fgets(STDIN))) != '' ? $input : $defaults['lastName'];
         } while ($lastName == '');
         do {
             printf('E-mail address: ');
             $emailAddress = trim(fgets(STDIN));
         } while ($emailAddress == '');
         do {
             printf('Password: '******'');
     } else {
         extract($defaults);
     }
     Wiz::getMagento();
     $versionInfo = Mage::getVersionInfo();
     try {
         // Create the user
         $userModel = Mage::getModel('admin/user')->setUsername($login)->setFirstname($firstName)->setLastname($lastName)->setEmail($emailAddress)->setPassword($password)->setIsActive(true)->save();
         // Load the role collection
         $collection = Mage::getResourceModel('admin/role_collection');
         // Only load the roles, not the relationships
         $collection->setRolesFilter();
         // Find the administrative role.
         foreach ($collection as $role) {
             if ($versionInfo['major'] == 1 && ($versionInfo['minor'] > 2 && $versionInfo['minor'] < 6) && $role->getGwsIsAll() == 1 || $role->getRoleName() == 'Administrators') {
                 $userRoles[] = $role->getId();
             }
         }
         // Set up the role relationship
         $userModel->setRoleIds($userRoles)->setRoleUserId($userModel->getUserId())->saveRelations();
         echo "Created new user '{$login}' with password '{$password}'." . PHP_EOL;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #28
0
 public function isMageVersionEqualOrGreater($version)
 {
     $version = explode('.', $version);
     $mageVersion = array_values(Mage::getVersionInfo());
     foreach ($version as $key => $value) {
         if ($key == 1 && Mage::getConfig()->getModuleConfig('Enterprise_Enterprise')->is('active', 'true')) {
             if ((int) $mageVersion[$key] < (int) ($value + 5)) {
                 return false;
             }
         } else {
             if ((int) $mageVersion[$key] < (int) $value) {
                 return false;
             }
         }
     }
     return true;
 }
Example #29
0
 public function isNewMagento()
 {
     $mage = new Mage();
     if (!is_callable(array($mage, 'getEdition'))) {
         $edition = 'Community';
     } else {
         $edition = Mage::getEdition();
     }
     unset($mage);
     $version = Mage::getVersionInfo();
     $m1 = $version['major'];
     $m2 = $version['minor'];
     $v = $m1 * 1000 + $m2 * 10;
     if ($edition == 'Enterprise') {
         if ($v >= 1140) {
             // 1.14
             return true;
         }
     } else {
         if ($v >= 1090) {
             // 1.9
             return true;
         }
     }
     return false;
 }
Example #30
0
 /**
  * Get Edition from version Info
  *
  * @param  array|boolean $versionInfo
  *
  * @return string|boolean
  */
 public function getEdition($versionInfo = false)
 {
     // Ensure we have version info
     if (!$versionInfo || !is_array($versionInfo)) {
         if (method_exists('Mage', 'getEdition')) {
             return Mage::getEdition();
         }
         $versionInfo = Mage::getVersionInfo();
     }
     // Get Edition from version
     if (array_key_exists('major', $versionInfo) && array_key_exists('minor', $versionInfo)) {
         $major = $versionInfo['major'];
         $minor = $versionInfo['minor'];
         if (1 == $major) {
             if ($minor < 9 || $minor == 9 && method_exists('Mage', 'getEdition')) {
                 return 'Community';
             } else {
                 if ($minor >= 9 && $minor < 11) {
                     return 'Professional';
                 } else {
                     if ($minor >= 11) {
                         return 'Enterprise';
                     }
                 }
             }
         }
     }
     return false;
 }