public function Log($message, $level = Zend_Log::DEBUG)
 {
     if ($this->isDebug() || $level < 5) {
         // log only if debug is enabled or is a warn or below error
         Mage::Log($message, $level, 'paymentech-log.log');
     }
 }
Example #2
0
 public function exportProducts($observer)
 {
     Mage::Log("exportProducts called!");
     echo "VPS Export Products called!";
     exit;
     //Mage::log($observer->getEvent()->getControllerAction()->getFullActionName());
 }
 public function addContainerBlock($observer)
 {
     #Mage::Log($_SERVER['SCRIPT_URI']);
     #Mage::Log("Start addContainerBlocks");
     $layout = Mage::getSingleton('core/layout');
     if (!$layout) {
         Mage::Log("No Layout Object in " . __METHOD__);
         return;
     }
     $before_body_end = $layout->getBlock('before_body_end');
     if (!$before_body_end) {
         Mage::Log("No before body end in " . __METHOD__);
         return;
     }
     if (!Mage::helper('segment_analytics')->isEnabled()) {
         return;
     }
     $container = $layout->createBlock('core/text_list', self::CONTAINER_BLOCKNAME);
     $before_body_end->append($container);
     $front = Segment_Analytics_Model_Front_Controller::getInstance();
     $blocks = $front->getBlocks();
     foreach ($blocks as $block) {
         if (!$block) {
             continue;
         }
         $items = $block = is_array($block) ? $block : array($block);
         foreach ($items as $block) {
             $container->append($block);
         }
     }
     #Mage::Log("Finished addContainerBlocks");
 }
Example #4
0
 public function format($thing)
 {
     $helper = $this->getShim()->helper('commercebug/formatlog_allsimple');
     if ($helper) {
         return $helper->format($thing);
     }
     Mage::Log(sprintf('Could not instantiate helper class: %s', $alias));
 }
 public function Log($message, $logname = "greatplains", $level = Zend_Log::DEBUG)
 {
     if ($this->isDebug() || $level < 5) {
         // log only if debug is enabled or
         // is a warn or below error
         Mage::Log(date("m-d-y G:i:s :: ", time()) . " : " . $message, $level, 'greatplains.' . $logname . '.log');
         //  echo date ( "m-d-y G:i:s :: ", time () ) ." : ".$message."\n";;
     }
 }
Example #6
0
 public function format($thing)
 {
     $helper = Mage::helper('commercebug/formatlog_allsimple');
     if ($helper) {
         return $helper->format($thing);
     }
     Mage::Log(sprintf('Could not instantiate helper class: %s', $alias));
     //return;
     #return __CLASS__ . 'Serialized:' . $thing;
 }
 /**
  * If object is in debug mode it returns all debug notifications to standard output
  * @param string $data
  */
 protected function debug()
 {
     if ($this->debugFlag === true) {
         $arg_list = func_get_args();
         foreach ($arg_list as $v) {
             Mage::Log('[Sheepla][' . date('Y-m-d H:i:s') . ']' . print_r($v, true));
             if ($this->forceDebugFlag) {
                 echo date('Y-m-d H:i:s') . ' : <pre>' . htmlentities(print_r($v, true)) . "</pre> <br />\n\r";
             }
         }
     }
 }
Example #8
0
 public function format($thing)
 {
     $alias = Mage::getStoreConfig('commercebug/options/log_format_class');
     if ($alias == 'custom') {
         $alias = Mage::getStoreConfig('commercebug/options/log_format_class_custom');
     }
     $helper = Mage::helper($alias);
     if ($helper) {
         return $helper->format($thing);
     }
     Mage::Log(sprintf('Could not instantiate helper class: %s', $alias));
     return $thing;
     #return __CLASS__ . 'Serialized:' . $thing;
 }
Example #9
0
 /**
  * Get Product information from qquote_request_item table
  * @return object
  */
 public function getRequestedProductData($id, $quoteId)
 {
     $prices = array();
     $aQty = array();
     $quote = Mage::getModel('qquoteadv/qqadvcustomer')->load($quoteId);
     $collection = Mage::getModel('qquoteadv/requestitem')->getCollection()->setQuote($quote)->addFieldToFilter('quote_id', $quoteId)->addFieldToFilter('quoteadv_product_id', $id);
     $collection->getSelect()->order('request_qty asc');
     $n = count($collection);
     if ($n > 0) {
         foreach ($collection as $requested_item) {
             $aQty[] = $requested_item->getRequestQty();
             $prices[] = $requested_item->getOwnerCurPrice();
             Mage::Log("CURPRICE" . $requested_item->getOwnerCurPrice());
         }
     }
     return $return = array('ownerPrices' => $prices, 'aQty' => $aQty);
 }
Example #10
0
 public function getHelpers($module)
 {
     try {
         $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($module . '/Helper'));
     } catch (UnexpectedValueException $e) {
         Mage::Log($e->getMessage());
         return '';
     }
     $options = array();
     while ($it->valid()) {
         if (!$it->isDot()) {
             $label = strtolower(str_replace('.php', '', str_replace('/', '_', $it->getSubPathName())));
             $options[$it->key() . '=>' . $label] = $label;
         }
         $it->next();
     }
     return $this->_toOptionsFromHash($options);
 }
Example #11
0
 private function _createCustomerAddress($customer)
 {
     Mage::Log("Year :::  " . $customer->getYear());
     //Validate and fill default values.
     $year = $customer->getYear() ? $customer->getYear() : "9999";
     $course = $customer->getCourse() ? $customer->getCourse() : "NA";
     $college = $customer->getCollege() ? $customer->getCollege() : "NA";
     $place = $customer->getPlace() ? $customer->getPlace() : "NA";
     $phone = $customer->getPhone() ? $customer->getPhone() : "9999999999";
     $_custom_address = array('firstname' => $customer->getFirstname(), 'lastname' => $customer->getLastname(), 'street' => array('0' => $year . ", " . $course, '1' => $college), 'city' => $place, 'region_id' => '', 'region' => '', 'postcode' => '0', 'country_id' => 'IND', 'telephone' => $phone);
     $customAddress = Mage::getModel('customer/address');
     $customAddress->setData($_custom_address)->setCustomerId($customer->getId())->setIsDefaultBilling('1')->setIsDefaultShipping('1')->setSaveInAddressBook('1');
     try {
         $customAddress->save();
         Mage::Log("Adding information success!!!");
     } catch (Exception $ex) {
         //Zend_Debug::dump($ex->getMessage());
         Mage::Log("Error in Address " . $ex->getMessage());
     }
     return;
 }
 public function Process($data)
 {
     $d = $data->CreateNewOrderResult;
     if (stristr($d, "Error occured Creating Order")) {
         $a = explode("Node Identifier Par", $d);
         $d = $a[0];
         $d = explode("Error Description = ", $d);
         $error = $d[1];
         $error = $a[0];
         Mage::Log($error, 1, "gp_new_order_error.log");
         Mage::Log(print_r($d, true), 1, "gp_new_order_error.log");
         $this->_errors = $error;
         return $this;
     }
     if (isset($data->return)) {
         $this->_errors = $data->return->error;
         return $this;
     }
     $this->_return[] = $data;
     return $this;
 }
Example #13
0
 protected function _getProductCollection()
 {
     // trying to override this method
     if (is_null($this->_x_productCollection)) {
         $collection = parent::_getProductCollection();
         $session = Mage::getSingleton('customer/session');
         $isCorporate = FALSE;
         if ($session->isLoggedIn()) {
             $customer = $session->getCustomer();
             $isCorporate = $customer->getZiscorporate();
         }
         if ($isCorporate == 470) {
             $collection->addTierPriceData();
             $collection->addAttributeToFilter('tier_price', 'notnull');
             // $collection->getSelect()->where("price_index.tier_price IS NOT NULL");
             Mage::Log("Rrap_Corporate_Block_Product_List select is " . $collection->getSelect());
         }
         $this->_productCollection = $collection;
     } else {
         $collection = parent::_getProductCollection();
     }
     return $collection;
 }
 public function paymentcallbackAction()
 {
     $data = $this->getRequest()->getPost();
     Mage::Log($data);
     if ($data['order_id'] && $data['appkey'] && $data['order_uid'] && $data['amount'] && $data['sign']) {
         $app_key = Mage::getStoreConfig('sns/sns_weibo/app_key');
         $debug = Mage::getStoreConfig('sns/sns_weibo/debug');
         $app_secret = Mage::getStoreConfig('sns/sns_weibo/app_secret');
         if ($app_key == $data['appkey']) {
             $signkey = md5($data['order_id'] . "|" . $data['appkey'] . "|" . $data['order_uid'] . "|" . $data['amount'] . "|" . $app_secret);
             if ($signkey == $data['sign']) {
                 echo $return = 'OK';
             } else {
                 echo $return = 'NOTVALIDSIGN';
             }
         } else {
             echo $return = 'NOTVALIDKEY';
         }
     } else {
         echo $return = 'EMPTYPOST';
     }
     Mage::Log($return);
     exit;
 }
 public function __call($method, $params)
 {
     Mage::log("_call");
     //Mage::log($method);
     //Mage::log($params);
     //die;
     foreach ($params as $k => $v) {
         Mage::log("-------------------------afasdfagfagfr------------------------");
         Mage::Log("k is : {$k}");
         $data = $this->generateValidXmlFromObj($v);
         Mage::Log($data);
         //	if(is_object($v))
         //		Mage::Log("v is object ".print_r($v,true));
         //		else
         //	Mage::Log("v is string ".$v);
         if ($v === null) {
             Mage::Log("SPOTTED A NULL YO!!!");
             $this->mustParseNulls = true;
             $params[$k] = self::_NULL_;
         }
     }
     //die;
     return parent::__call($method, $data);
 }
Example #16
0
 public function forceSyncOrderAction()
 {
     if (!$this->isSecureKeyValid()) {
         die('Access Denied.');
     }
     $incrementOrderId = (int) strip_tags(Mage::app()->getRequest()->getParam('id', 0));
     $magentoOrder = Mage::getModel('sales/order')->loadByIncrementId($incrementOrderId);
     //get order from magento table
     $sheeplaOrderModel = Mage::getModel('sheepla/order');
     $isSheeplaOrderAlreadyExist = count($sheeplaOrderModel->getCollection()->addFieldToFilter('order_id', $incrementOrderId));
     //in orba_sheepla_order table
     if ($incrementOrderId && $isSheeplaOrderAlreadyExist && count($magentoOrder) && preg_match('/sheepla\\_method\\_/', $magentoOrder['shipping_method'])) {
         $sheeplaProxyModel = Mage::getModel('sheepla/proxy');
         $result = $sheeplaProxyModel->forceSyncOrder($magentoOrder);
         //force sync current order
         $sheeplaOrderModel->load($result[0]['orderId'], 'order_id');
         $sheeplaOrderModel->setSyncFields($result[0]);
         //change last_sync_on var
         Zend_Debug::dump($result);
         //print result
     } else {
         echo "Error";
         Mage::Log('[Sheepla][Error][Orba_Sheepla_IndexController::forceSyncOrderAction] not found incrementOrderId: ' . $incrementOrderId . ' or this is not order using sheepla.');
     }
 }
 /**
  * Updates Magento products with data from GP.
  *
  * @param $data - data from GP.
  * @return bool
  */
 public function _updateProductData($data, $gpSku = null)
 {
     /* Get downloadable tax class */
     static $downloadableClass;
     if (is_null($downloadableClass)) {
         $classes = Mage::getModel('tax/class')->getCollection()->addFieldToFilter('class_name', array('eq' => 'Downloadable'))->load();
         if ($classes->count()) {
             $downloadableClass = $classes->getFirstItem();
         } else {
             $downloadableClass = Mage::getModel('tax/class');
             $downloadableClass->setData(array('class_name' => 'Downloadable', 'class_type' => 'PRODUCT'));
             $downloadableClass->save();
         }
     }
     //  Mage::Log($data, Zend_Log::DEBUG, 'gp_product_cron.log');
     /*
      * Check for empty data sets. If all are empty, return false for this sku.
      */
     $gotData = false;
     $gotDescription = false;
     $gotWeight = false;
     $gotInventory = false;
     $gotTaxability = false;
     $gotTierPricing = false;
     if (isset($data->Description) && $data->Description != "") {
         $gotDescription = true;
         $gotData = true;
     }
     if (isset($data->Weight) && $data->Weight != "") {
         $gotWeight = true;
         $gotData = true;
     }
     if (isset($data->Inventory) && $data->Inventory != "") {
         $gotInventory = true;
         $gotData = true;
     }
     if (isset($data->Taxability) && $data->Taxability != "") {
         $gotTaxability = true;
         $gotData = true;
     }
     if (!empty($data->TierPricing) && is_object($data->TierPricing)) {
         $gotTierPricing = true;
         $gotData = true;
     }
     if (!$gotData) {
         $this->log("No data from GP for gp_sku = " . $gpSku);
     } else {
         $this->log("Data found from GP for gp_sku = " . $gpSku);
     }
     /*
      * Get the set of Magento products that have this GP_SKU
      */
     $sku = empty($data->SKU) ? $gpSku : $data->SKU;
     $originalPrice = 0;
     $products = $this->getProductCollection();
     $products = $products->addAttributeToFilter('gp_sku', $sku)->addAttributeToSelect('price')->addAttributeToSelect('visibility')->addTierPriceData()->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID);
     /*
      * Update product information for each product with this gp_sku
      */
     foreach ($products as $product) {
         if ($gotData) {
             $this->numProdsWData++;
         } else {
             $this->numProdsNoData++;
         }
         $this->log("\tFound product with sku = " . $product->getSku());
         /*
          * Process and update pricing from GP.
          */
         $originalPrice = $product->getPrice();
         if ($gotTierPricing) {
             $this->log("\t\tProcessing new tier prices");
             $tierpricing = $data->TierPricing;
             $tierpricing = (array) $tierpricing;
             // Loop through GP tier pricing data and accumulate it in newTierPrices
             $newTierPrices = array();
             foreach ($tierpricing as $group => $prices) {
                 foreach ($prices->PriceTier as $gpPriceTier) {
                     $gpPriceTier = (array) $gpPriceTier;
                     $mageTiers = $this->processPrice($group, $gpPriceTier);
                     foreach ($mageTiers as $singleTier) {
                         $newTierPrices[] = $singleTier;
                         // Iron Eyes Cody
                     }
                 }
             }
             // Mage::Log($newTierPrices, Zend_Log::DEBUG, 'gp_product_test.log');
             // Set product's regular price to first tier that meets qualifications.
             // There should only be one anyhow.
             foreach ($newTierPrices as $tier) {
                 if ($tier['price_qty'] == 1 && !$this->isCustGroupElevated($tier['cust_group'])) {
                     $originalPrice = $tier['price'];
                     break;
                 }
             }
             /*
              * Retain existing tiers that are not part of the set of tiers that are updated from GP.
              */
             $existingTierPrice = $product->getData('tier_price');
             Mage::Log($existingTierPrice, Zend_Log::DEBUG, 'gp_product_test.log');
             if ($existingTierPrice) {
                 $this->log("\t\tHad existing tiers. Special values will be retained.");
                 foreach ($existingTierPrice as $tp) {
                     if (!$this->isCustGroupPricingUpdateFromGP($tp['cust_group'])) {
                         $this->log("\t\tNot In group list - ALL,NOT LOGGED IN,General,Member,Reseller,HIDDEN_Reseller will not overwritten");
                         $newTierPrices[] = $tp;
                     } else {
                         //$this->log("\t\tIn group list - ALL,NOT LOGGED IN,General,Member,Reseller,HIDDEN_Reseller will overwritten");
                         $this->log("\t\tIn group list - ALL,NOT LOGGED IN,General,Member,Reseller,HIDDEN_Reseller will overwritten if such a tier already exists");
                         if (!$this->checkTierExists($tp, $newTierPrices)) {
                             $newTierPrices[] = $tp;
                         }
                     }
                 }
                 Mage::Log($newTierPrices, Zend_Log::DEBUG, 'gp_product_test.log');
             }
         }
         /*
          * Process and update weight
          * Ignores weights of 0 from GP.
          */
         if ($gotWeight) {
             if ($data->Weight > 0) {
                 $this->log("\t\tGot a new non-zero weight.");
                 if ($product->getTypeId() == 'simple') {
                     $product->setWeight($data->Weight);
                 }
             }
         }
         /* ticket#2014112010000245 - only update inventory and taxability when product is not "virtual" and "event" */
         $isEvent = $product->getData('type_id') == 'virtual' && $product->getData('attribute_set_id') == 11;
         /*
          * Process and update inventory
          */
         $stockData = array();
         if ($gotInventory && !$isEvent) {
             $this->log("\t\tSetting new inventory data");
             $stockData['qty'] = $data->Inventory;
             // Set is_in_stock properly based on qty and (if necessary) backorderable
             // Note: if qty <= 0 and it is backorderable, we leave is_in_stock as is.
             if ($data->Inventory > 0) {
                 $stockData['is_in_stock'] = 1;
             } else {
                 $isBackorderable = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getBackorders();
                 if ($isBackorderable == "0") {
                     $stockData['is_in_stock'] = 0;
                 }
             }
             /*                 * * start. artem. gorilla. ticket 2012120710000352 ** */
             //$product->setStockItem($stockData);
             $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
             $product->setStockItem($stockItem);
             $product->setStockData($stockData);
             /*                 * * end. artem. gorilla. ticket 2012120710000352 ** */
         } else {
             $this->log("\t\tgotInventory -- " . $gotInventory . " --- isevent" . $isEvent);
             $stockData = $product->getStockItem();
             if ($stockData->getUseConfigManageStokck() == 0) {
                 $stockData->setData('qty', 0);
                 $stockData->setData('is_in_stock', 1);
                 $stockData->setData('manage_stock', 0);
                 $stockData->setData('use_config_manage_stock', 0);
                 //  $stockData->save(); // This enough to save stock data.
                 $product->setStockItem($stockData);
             }
         }
         /*
          * Process and update taxability
          */
         if ($product->getTypeId() == 'downloadable') {
             $product->setTaxClassId($downloadableClass->getId());
         } else {
             if ($gotTaxability && !$isEvent) {
                 $this->log("\t\tSetting new tax data --- " . $data->Taxability);
                 switch ($data->Taxability) {
                     case "Basedoncustomer":
                     case "BasedOnCustomer":
                         $this->log("\t\tnew tax data -- 2");
                         $product->setTaxClassId(2);
                         break;
                     case "NonTaxable":
                     case "Nontaxable":
                         $this->log("\t\tnew tax data -- 0");
                         $product->setTaxClassId(0);
                         break;
                     default:
                         $this->log("\t\tnew tax data -- 2");
                         $product->setTaxClassId(2);
                         break;
                 }
             }
         }
         /*
          * Update with time we ran this.
          */
         $product->setLastGpUpdate($this->getScriptStartTime());
         /**
          * Save the product.
          */
         try {
             $this->log("\t\tSaving product");
             $product->setPrice($originalPrice);
             // If we have new tier pricing data, there's a two step save process:
             //      1) first we unset the current tier price, then we save,
             //      2) then we set the new tier price, and then go with the regular save
             if ($gotTierPricing) {
                 $this->log("\t\tGotTierPricing");
                 $product->setData(self::ATTRIBUTE_CODE, array());
                 $product->setData('tier_price_changed', 1);
                 $this->log("\t\tbefore save 1");
                 $product->save();
                 $this->log("\t\tafter save 1");
                 time_nanosleep(0, 10000000);
                 // this is 1/100th of a second.
                 $this->log("\t\\after nano");
                 $product->setData(self::ATTRIBUTE_CODE, $newTierPrices);
                 $this->log("\t\tafter setting new tiers");
             }
             $product->save();
             $this->log("\t\tSaved");
         } catch (Exception $e) {
             $line = "Integrity constraint violation";
             // We are supressing this error.
             if (strpos($e->getMessage(), $line) === false) {
                 $this->log("Error saving product. Sku = " . $product->getSku . ". Error: " . $e->getMessage());
             }
         }
     }
     return $gotData;
 }
Example #18
0
 /**
  * Post new shipment to ChannelEngine. This function is set in extension config file.
  *
  * @param Varien_Event_Observer $observer
  * @return bool
  * @throws Exception
  */
 public function saveShipment(Varien_Event_Observer $observer)
 {
     Mage::log('--------------------------------------');
     $event = $observer->getEvent();
     /** @var $_shipment Mage_Sales_Model_Order_Shipment */
     $_shipment = $event->getShipment();
     /** @var $_order Mage_Sales_Model_Order */
     $_order = $_shipment->getOrder();
     $storeId = $_order->getStoreId();
     $ceOrder = Mage::getModel('channelengine/order')->loadByOrderId($_order->getId());
     $ceOrderId = $ceOrder->getChannelOrderId();
     if (!$ceOrderId) {
         return false;
     }
     // Check if the API client was initialized for this order
     if (!isset($this->_client[$storeId])) {
         return false;
     }
     // Initialize new ChannelEngine shipment object
     $ceShipment = new Tritac_ChannelEngineApiClient_Models_Shipment();
     $ceShipment->setOrderId($ceOrderId);
     $ceShipment->setMerchantShipmentNo($_shipment->getId());
     // Set tracking info if available
     $trackingCode = null;
     $trackingCodes = $_shipment->getAllTracks();
     if (count($trackingCodes) > 0) {
         $trackingCode = $trackingCodes[0];
         $ceShipment->setTrackTraceNo($trackingCode->getNumber());
         $ceShipment->setMethod($trackingCode->getTitle());
     }
     // If the shipment is already known to ChannelEngine we will just update it
     $_channelShipment = Mage::getModel('channelengine/shipment')->loadByShipmentId($_shipment->getId());
     if ($_channelShipment->getId() != null) {
         if ($trackingCode != null) {
             Mage::Log("TrackTrace: {$trackingCode->getNumber()}");
         }
         Mage::log("CE Shipment Id: #{$_channelShipment->getChannelengineShipmentId()}");
         $ceShipment->setId($_channelShipment->getChannelengineShipmentId());
         $this->_client[$storeId]->putShipment($ceShipment);
         return true;
     }
     Mage::log('New shipment, continue');
     // Add the shipment lines
     $ceShipmentLines = new Tritac_ChannelEngineApiClient_Helpers_Collection('Tritac_ChannelEngineApiClient_Models_ShipmentLine');
     foreach ($_shipment->getAllItems() as $_shipmentItem) {
         // Get the quantity for this shipment
         $shippedQty = (int) $_shipmentItem->getQty();
         if ($shippedQty == 0) {
             continue;
         }
         // Get the original order item
         $_orderItem = Mage::getModel('sales/order_item')->load($_shipmentItem->getOrderItemId());
         if ($_orderItem == null) {
             continue;
         }
         $ceShipmentLine = new Tritac_ChannelEngineApiClient_Models_ShipmentLine();
         $ceShipmentLine->setOrderLineId($_orderItem->getChannelengineOrderLineId());
         $ceShipmentLine->setQuantity($shippedQty);
         $ceShipmentLine->setStatus(Tritac_ChannelEngineApiClient_Enums_ShipmentLineStatus::SHIPPED);
         $ceShipmentLines->append($ceShipmentLine);
     }
     // Check if there are any shipment lines
     if (count($ceShipmentLines) == 0) {
         return false;
     }
     $ceShipment->setLines($ceShipmentLines);
     // Post shipment to ChannelEngine
     try {
         $result = $this->_client[$storeId]->postShipment($ceShipment);
         if ($result == null) {
             return false;
         }
         $_channelShipment = Mage::getModel('channelengine/shipment')->setShipmentId($_shipment->getId())->setChannelengineShipmentId($result->getId());
         $_channelShipment->save();
         Mage::log("Shipment #{$_shipment->getId()} (CE #{$result->getId()}) was placed successfully.");
     } catch (Exception $e) {
         Mage::getModel('adminnotification/inbox')->addCritical("A shipment (#{$_shipment->getId()}) could not be exported", "Please contact ChannelEngine support at <a href='mailto:support@channelengine.com'>support@channelengine.com</a> or +31(0)71-5288792");
         Mage::logException($e);
     }
     return true;
 }
	function log($message) {
		echo $message . "\n";
		Mage::Log(date("m-d-y G:i:s :: ", time()) . " : " . $message, 3, 'historical_import.log');
	}
Example #20
0
 /**
  * Export selected quotes as csv
  */
 public function exportAction()
 {
     if (!Mage::helper('qquoteadv')->validLicense('export')) {
         $this->_redirectErr($this->__('The CSV export function is only available in Cart2Quote Enterprise. 
       To update please go to <a href="http://www.cart2quote.com/pricing-magento-quotation-module.html?utm_source=Customer%2Bwebsite&utm_medium=license%2Bpopup&utm_campaign=Upgrade%2Bversion">http://www.cart2quote.com</a>'));
         return;
     }
     $quoteIds = $this->getRequest()->getParam('qquote');
     if (!is_array($quoteIds) || empty($quoteIds)) {
         $this->_redirectErr($this->__('No quotes selected to export'));
         return;
     }
     $folder = Mage::getBaseDir() . self::EXPORT_FOLDER_PATH;
     $filename = "cart2quoteExport_" . date("ymdHis") . ".csv";
     //check the folder exists or create it
     if (!file_exists($folder)) {
         try {
             mkdir($folder);
         } catch (Exception $e) {
             Mage::Log($e->getMessage());
             $this->_redirectErr($this->__('Could not create cart2quote export folder: ') . $folder);
             return;
         }
     } else {
         if (!is_writable($folder)) {
             $this->_redirectErr($this->__('The cart2quote export folder is not writable: ') . $folder);
             return;
         }
     }
     //set filepath
     $filepath = $folder . $filename;
     //export quotes to file
     $exported = Mage::getSingleton('qquoteadv/qqadvcustomer')->exportQuotes($quoteIds, $filepath);
     if ($exported) {
         $contents = file_get_contents($filepath);
         $this->_prepareDownloadResponse($filename, $contents);
     } else {
         $this->_redirectErr($this->__('Could not export quotes'));
         return;
     }
 }
Example #21
0
 public function EnviaGateway(Varien_Object $payment, $xml)
 {
     /*
      * Faz o envio do XML para o gateway de pagamento.
      */
     $status = "";
     $orderId = $payment->getParentId();
     $url = 'https://www.akatus.com/api/v1/carrinho.xml';
     #$url = 'https://dev.akatus.com/api/v1/carrinho.xml';
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $url);
     #curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
     # curl_setopt($curl, CURLOPT_USERPWD, $user . ":" . $passwd);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0");
     curl_setopt($curl, CURLOPT_POST, true);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $ret = curl_exec($curl);
     $err = curl_error($curl);
     curl_close($curl);
     $data = $this->xml2array($ret);
     #Criado para facilitar o ambiente de depuração.
     if ($this->getConfigData('module_debug') == '1') {
         Mage::throwException("XML RECEBIDO:\n\n" . $ret . "\n\n\nXML Enviado:\n" . $xml);
     }
     Mage::Log("..:: ENVIADO ::..\n\n" . $xml . "\n\n ..:: RECEBIDO ::..\n\n" . $ret);
     /*
     print_r($ret);
     print_r($data);	
     */
     //echo "<br />Status:".$data["resposta"]["status"]["value"];
     $info = $this->getInfoInstance();
     $formapagamento = $info->getCheckFormapagamento();
     //print_r($formadepagamento);
     //exit();
     if ($data["resposta"]["status"]["value"] == "erro") {
         #exibe a mensagem de erro
         Mage::Log('Deu erro meu velho: ' . $data["resposta"]["descricao"]["value"]);
         Mage::throwException("Não foi possível realizar sua transação");
         #exibe a mensagem de erro
         #Mage::getSingleton('checkout/session')->addError(Mage::helper('checkout')->__("Não foi possivel realizar sua transação"));
     } else {
         //echo "Não deu erro, retornou algum outro status";
         if ($data["resposta"]["status"]["value"] == "Em Análise") {
             //echo "Em análise";
             //exit;
             //Salva no sistema o ID da transação
             Mage::Log('Veio Em Análise, passou o cartão, é setar o status e partir pro abraço.');
             try {
                 $transacaoId = $data["resposta"]["transacao"]["value"];
                 $this->SalvaIdTransacao($orderId, $transacaoId);
                 $order = Mage::getModel('sales/order')->load($orderId);
                 $order->setStatus('pending_payment');
                 $order->save();
                 $info = $this->getInfoInstance();
                 $formadepagamento = $info->getCheckFormapagamento();
                 //Mage::throwException($formadepagamento);
                 //Mage::throwException("Seu pedido foi realizado com sucesso. Estamos aguardando a confirmação de sua administradora e assim que o pagamento for liberado enviaremos o produto");
                 $msg = "Seu pedido foi realizado com sucesso. Estamos aguardando a confirmação de sua administradora e assim que o pagamento for liberado enviaremos o produto";
                 Mage::getSingleton('checkout/session')->addSuccess(Mage::helper('checkout')->__($msg));
             } catch (Exception $e) {
                 $e->getMessage();
             }
         } elseif ($data["resposta"]["status"]["value"] == "Aguardando Pagamento" || $data["resposta"]["status"]["value"] == "Processando") {
             $info = $this->getInfoInstance();
             $formapagamento = $info->getCheckFormapagamento();
             //ge::throwException($formadepagamento);
             //$url_destino='https://www.akatus.com/boleto/';
             if ($formapagamento == "boleto") {
                 #$url_destino='https://dev.akatus.com/boleto/';
                 $url_destino = 'https://www.akatus.com/boleto/';
                 $str = $data['resposta']['transacao']['value'];
                 $url_destino .= base64_encode($str) . '.html';
                 $payment->setCheckBoletourl($url_destino);
                 $payment->save();
                 $transacaoId = $data["resposta"]["transacao"]["value"];
                 $this->SalvaIdTransacao($orderId, $transacaoId);
                 #monta a mensagem
                 #$msg="<img src =
                 $msg = 'Transação realizada com sucesso. Clique na url abaixo para imprimir seu boleto.<br/>';
                 $msg .= "<a href='" . $url_destino . "' target='_blank'>" . $url_destino . "</a>";
                 Mage::getSingleton('checkout/session')->addSuccess(Mage::helper('checkout')->__($msg));
             }
             if ($formapagamento == "tef") {
                 #$url_destino='https://dev.akatus.com/tef/';
                 $url_destino = 'https://www.akatus.com/tef/';
                 $str = $data['resposta']['transacao']['value'];
                 $url_destino .= base64_encode($str) . '.html';
                 $transacaoId = $data["resposta"]["transacao"]["value"];
                 $this->SalvaIdTransacao($orderId, $transacaoId);
                 #monta a mensagem
                 $msg = 'Transação realizada com sucesso. Clique na url abaixo e você será redirecionado para seu banco.<br/>';
                 $msg .= "<a href='" . $url_destino . "' target='_blank'>" . $url_destino . "</a>";
                 Mage::getSingleton('checkout/session')->addSuccess(Mage::helper('checkout')->__($msg));
             }
         } else {
             //			$info = $this->getInfoInstance();
             //         $formapagamento=$info->getCheckFormapagamento();
             Mage::throwException("Pagamento não autorizado. Consulte sua operadora para maiores informações.");
             //$msq = "Pagamento não autorizado. Consulte sua operadora para maiores informações.";
             //Mage::throwException("Cartão Recusado:".$data["resposta"]["status"]["value"]."<br />Forma de pagamento:".$formadepagamento);
         }
     }
 }
Example #22
0
 public static function log($string)
 {
     Mage::Log($string);
 }
Example #23
0
 public function getNextId()
 {
     //Payment method codes using Order Id Creation
     $cod = 'C';
     // Cash On Delivery
     $chod = 'H';
     // Cheque On Delivery
     $credit = 'F';
     // Credit Normal
     $payu = 'P';
     //PayU Payment Method
     $neft = 'N';
     // Bank Transfer
     $corporate = 'X';
     // Corporate Companies
     if (strpos($last, $this->getPrefix()) === 0) {
         $last = (int) substr($last, strlen($this->getPrefix()));
     } else {
         $last = (int) $last;
     }
     $date = date("ymd", Mage::app()->getLocale()->storeTimeStamp(1));
     // Get Current date
     if (Mage::app()->getStore()->isAdmin()) {
         $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
         if ($quote->getId()) {
             $paymentcode = $quote->getPayment()->getMethodInstance()->getCode();
             // Get Payment method from Quote
         } else {
             //Admin Invoice and Shipment Id generation
             $write = Mage::getSingleton('core/resource')->getConnection('core_write');
             $result = $write->query("SELECT temp.rnd FROM sales_flat_order c,(SELECT FLOOR((RAND()*999999999)) AS rnd FROM sales_flat_order LIMIT 0,25) AS temp\n\t\t\t\t\t\t\t WHERE c.increment_id NOT IN (temp.rnd) LIMIT 1");
             $random = $result->fetch();
             $next = $random['rnd'];
             return $this->format($next);
         }
     } else {
         $quote = Mage::getSingleton('checkout/session')->getQuote();
         Mage::Log("Numeric.php : quote in session is " . $quote->getId());
         if ($quote->getId()) {
             $paymentcode = $quote->getPayment()->getMethodInstance()->getCode();
             // Get Payment method from Quote
         } else {
             //PayU Orders
             $customer = Mage::getSingleton('customer/session')->getCustomer();
             if ($customer->getId()) {
                 $cust = new Mage_Customer_Model_Customer();
                 //$cust->setEmail($customer->getEmail())->save();
                 $cust->loadByEmail($customer->getEmail())->save();
                 return;
             } else {
                 $write = Mage::getSingleton('core/resource')->getConnection('core_write');
                 $result = $write->query("SELECT temp.rnd FROM sales_flat_order c,(SELECT FLOOR((RAND()*999999999)) AS rnd FROM sales_flat_order LIMIT 0,25) AS temp\n\t\t\t\t\t\t\t WHERE c.increment_id NOT IN (temp.rnd) LIMIT 1");
                 $random = $result->fetch();
                 $next = $random['rnd'];
                 return $this->format($next);
             }
         }
     }
     if ($paymentcode == 'cashondelivery') {
         $payCode = $cod;
     } elseif ($paymentcode == 'checkmo') {
         $payCode = $chod;
     } elseif ($paymentcode == 'payucheckout_shared') {
         $payCode = $payu;
     } elseif ($paymentcode == 'rcredit') {
         $payCode = $credit;
     } elseif ($paymentcode == 'bankpayment') {
         $payCode = $neft;
     }
     $orderIdVal = $date . $payCode . "-";
     //$next = $last+1;
     $write = Mage::getSingleton('core/resource')->getConnection('core_write');
     //$result= $write->query("SELECT temp.rnd FROM sales_flat_order c,(SELECT CONCAT('".$orderIdVal."',FLOOR((RAND()*99999))) AS rnd FROM sales_flat_order LIMIT 0,25) AS temp
     //WHERE c.increment_id NOT IN (temp.rnd) LIMIT 1");
     $result = $write->query("SELECT temp.rnd FROM sales_flat_order c,(SELECT CONCAT('" . $orderIdVal . "',FLOOR((RAND()*(99999-10000)+10000))) AS rnd FROM sales_flat_order LIMIT 0,25) AS temp\n    \t\t WHERE c.increment_id NOT IN (temp.rnd) LIMIT 1");
     $random = $result->fetch();
     $next = $random['rnd'];
     return $this->format($next);
 }
 private function orderQueuelog($q)
 {
     Mage::Log($q, Zend_Log::DEBUG, 'gp_OrderQueue.log');
 }
Example #25
0
 public function addCouponCodeFromUrl($observer)
 {
     $request = Mage::app()->getRequest();
     $response = Mage::app()->getResponse();
     $headers_original = $response->getHeaders();
     $param = $request->getParam(self::COUPON_PARAM);
     if (!$param) {
         return;
     }
     try {
         $message = Mage::getModel('curebit_socialreferrals/add')->addCoupon($request);
     } catch (Exception $e) {
         $message = $e->getMessage();
     }
     //reapply headers to un-do redirect added to by coupon adding code
     $response->clearHeaders();
     foreach ($headers_original as $item) {
         $response->setHeader($item['name'], $item['value'], $item['replace']);
     }
     Mage::Log($message, Zend_Log::INFO);
 }
Example #26
0
 public function Customerlogout($observer)
 {
     Mage::Log('Customer Logout Event');
     //Mage::getModel('core/cookie')->delete('Bulk');
 }
 public function successAction()
 {
     $order_id = Mage::app()->getRequest()->getParam('order_id');
     if ($order_id != "" && $order_id == Mage::getSingleton("customer/session")->getVerifyorder()) {
         $order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
         $order->sendNewOrderEmail();
         $this->loadLayout();
         $this->renderLayout();
     } else {
         Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
         Mage::Log("successAction : Enter");
         $session = $this->getOnepage()->getCheckout();
         if (!$session->getLastSuccessQuoteId()) {
             #Mage::Log("successAction : last success quote id not found ... redirecting");
             $this->_redirect('checkout/cart');
             return;
         }
         $quote = Mage::getModel('sales/quote')->load($session->getLastSuccessQuoteId());
         $payment_method_code = $quote->getPayment()->getMethodInstance()->getCode();
         if ($payment_method_code != "creditsale") {
             $lastOrderId = $session->getLastOrderId();
             if ($lastOrderId) {
                 $order = Mage::getModel('sales/order')->load($lastOrderId);
                 $payment_method_code1 = $order->getPayment()->getMethodInstance()->getCode();
                 if (Mage::getSingleton('checkout/session')->getPayRandomVal() == 0 && $payment_method_code1 == 'payucheckout_shared') {
                     //Mage::getSingleton('checkout/session')->clear();
                     $this->_redirect('no-route');
                     return;
                 }
                 if (Mage::getSingleton('checkout/session')->getPaymRandomVal() == 0 && $payment_method_code1 == 'payumoney_shared') {
                     //Mage::getSingleton('checkout/session')->clear();
                     $this->_redirect('no-route');
                     return;
                 }
             } else {
                 $this->_redirect('checkout/cart');
                 return;
             }
             if (!$session->getLastSuccessQuoteId()) {
                 $this->_redirect('checkout/cart');
                 return;
             }
             $lastQuoteId = $session->getLastQuoteId();
             $lastRecurringProfiles = $session->getLastRecurringProfileIds();
             if (!$lastQuoteId || !$lastOrderId && empty($lastRecurringProfiles)) {
                 $this->_redirect('checkout/cart');
                 return;
             }
         }
         $session->clear();
         $this->loadLayout();
         $this->_initLayoutMessages('checkout/session');
         if ($payment_method_code != 'creditsale') {
             Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
         }
         $this->renderLayout();
     }
 }
 function log($message)
 {
     echo $message . "\n";
     Mage::Log($message, Zend_Log::DEBUG, 'gp_order_cron.log');
 }
Example #29
0
 public function sentAnonymousData($action, $location)
 {
     $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'no-domain.com';
     $level = $this->getAccessLevel();
     if ($level == null) {
         $level = 0;
     }
     $is_trial = $this->_expiryDate === false ? false : true;
     $version = Mage::getVersion();
     $params = array("domain" => $domain, "action" => $action, "location" => $location, "level" => $level, "is_trial" => $is_trial, "version" => $version);
     try {
         $client = Mage::getModel('qquoteadv/client')->sendRequest($params);
     } catch (Exception $e) {
         Mage::Log($e->getMessage());
     }
 }
Example #30
0
 /**
  * This function is called when a visitor searches
  *
  * @param Mage_CatalogSearch_Model_Fulltext $object
  * @param string $queryText
  * @param Mage_CatalogSearch_Model_Query $query
  * @return JeroenVermeulen_Solarium_Model_Resource_CatalogSearch_Fulltext
  */
 public function prepareResult($object, $queryText, $query)
 {
     if (JeroenVermeulen_Solarium_Model_Engine::isEnabled($query->getStoreId())) {
         $helper = Mage::helper('jeroenvermeulen_solarium');
         $adapter = $this->_getWriteAdapter();
         $searchResultTable = $this->getTable('catalogsearch/result');
         $catSearchHelper = Mage::helper('catalogsearch');
         $stringHelper = Mage::helper('core/string');
         $thisQueryLength = $stringHelper->strlen($queryText);
         $wordsFull = $stringHelper->splitWords($queryText, true);
         $wordsLike = $stringHelper->splitWords($queryText, true, $catSearchHelper->getMaxQueryWords());
         /* Validate strings and return normal search to handle messages */
         if ($catSearchHelper->getMaxQueryLength() < $thisQueryLength || $catSearchHelper->getMinQueryLength() > $thisQueryLength || count($wordsFull) > count($wordsLike)) {
             return parent::prepareResult($object, $queryText, $query);
         }
         /** @var JeroenVermeulen_Solarium_Model_Engine $engine */
         $engine = Mage::getSingleton('jeroenvermeulen_solarium/engine');
         if ($engine->isWorking()) {
             $searchResult = $engine->search($query->getStoreId(), $queryText);
             $searchResult->setUserQuery($queryText);
             Mage::register('solarium_search_result', $searchResult);
             if (!$searchResult->getResultCount()) {
                 // Autocorrect
                 if ($engine->getConf('results/autocorrect', $query->getStoreId())) {
                     $searchResult->autoCorrect();
                 }
             }
             $resultProducts = $searchResult->getResultProducts();
             if (!$searchResult->getResultCount()) {
                 // No results, we need to check if the index is empty.
                 if ($engine->isEmpty($query->getStoreId())) {
                     Mage::Log(sprintf('%s - Warning: index is empty', __CLASS__), Zend_Log::WARN);
                 } else {
                     $query->setIsProcessed(1);
                 }
             } else {
                 $columns = array('query_id', 'product_id', 'relevance');
                 $insertRows = array();
                 $queryId = $query->getId();
                 foreach ($resultProducts as $data) {
                     $insertRows[] = array($queryId, $data['product_id'], $data['relevance']);
                 }
                 $adapter->beginTransaction();
                 $adapter->delete($searchResultTable, 'query_id = ' . $queryId);
                 $adapter->insertArray($searchResultTable, $columns, $insertRows);
                 $adapter->commit();
                 $query->setIsProcessed(1);
             }
             // Autocorrect notification
             if ($searchResult->didAutoCorrect()) {
                 $catSearchHelper->addNoteMessage($helper->__("Showing results for '%s' instead.", $searchResult->getResultQuery()));
             }
             // "Did you mean" suggestions
             $suggestions = $searchResult->getBetterSuggestions();
             if ($suggestions) {
                 $suggestHtml = '';
                 foreach ($suggestions as $searchTerm => $result_count) {
                     $title = $helper->__('Results') . ': ' . $result_count;
                     $href = Mage::getUrl('catalogsearch/result', array('q' => $searchTerm));
                     $suggestHtml .= sprintf('&nbsp; <a title="%s" href="%s">%s</a>', $title, $href, $searchTerm);
                 }
                 $catSearchHelper->addNoteMessage($helper->__('Did you mean:') . $suggestHtml);
             }
             /** @deprecated The registry key 'solarium_suggest' is deprecated, it was used in 1.6.0 till 1.6.2 */
             Mage::register('solarium_suggest', $searchResult->getBetterSuggestions());
         }
     }
     if (!$query->getIsProcessed()) {
         Mage::log('Solr disabled or something went wrong, fallback to Magento Fulltext Search', Zend_Log::WARN);
         return parent::prepareResult($object, $queryText, $query);
     }
     return $this;
 }