当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Object::setMessage方法代码示例

本文整理汇总了PHP中Varien_Object::setMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::setMessage方法的具体用法?PHP Varien_Object::setMessage怎么用?PHP Varien_Object::setMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Object的用法示例。


在下文中一共展示了Varien_Object::setMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveAction

 /**
  * Save shipment
  * We can save only new shipment. Existing shipments are not editable
  *
  * @return null
  */
 public function saveAction()
 {
     $data = $this->getRequest()->getPost('shipment');
     if (!empty($data['comment_text'])) {
         Mage::getSingleton('adminhtml/session')->setCommentText($data['comment_text']);
     }
     try {
         $shipment = $this->_initShipment();
         if (!$shipment) {
             $this->_forward('noRoute');
             return;
         }
         $shipment->register();
         $comment = '';
         if (!empty($data['comment_text'])) {
             $shipment->addComment($data['comment_text'], isset($data['comment_customer_notify']), isset($data['is_visible_on_front']));
             if (isset($data['comment_customer_notify'])) {
                 $comment = $data['comment_text'];
             }
         }
         if (!empty($data['send_email'])) {
             $shipment->setEmailSent(true);
         }
         $shipment->getOrder()->setCustomerNoteNotify(!empty($data['send_email']));
         $responseAjax = new Varien_Object();
         $isNeedCreateLabel = isset($data['create_shipping_label']) && $data['create_shipping_label'];
         if ($isNeedCreateLabel && $this->_createShippingLabel($shipment)) {
             $responseAjax->setOk(true);
         }
         $this->_saveShipment($shipment);
         Mage::dispatchEvent('sales_order_shipment_save_custom', array('post' => $data, 'shipment' => $shipment));
         $shipment->sendEmail(!empty($data['send_email']), $comment);
         $shipmentCreatedMessage = $this->__('The shipment has been created.');
         $labelCreatedMessage = $this->__('The shipping label has been created.');
         $this->_getSession()->addSuccess($isNeedCreateLabel ? $shipmentCreatedMessage . ' ' . $labelCreatedMessage : $shipmentCreatedMessage);
         Mage::getSingleton('adminhtml/session')->getCommentText(true);
     } catch (Mage_Core_Exception $e) {
         if ($isNeedCreateLabel) {
             $responseAjax->setError(true);
             $responseAjax->setMessage($e->getMessage());
         } else {
             $this->_getSession()->addError($e->getMessage());
             $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
         }
     } catch (Exception $e) {
         Mage::logException($e);
         if ($isNeedCreateLabel) {
             $responseAjax->setError(true);
             $responseAjax->setMessage(Mage::helper('sales')->__('An error occurred while creating shipping label.'));
         } else {
             $this->_getSession()->addError($this->__('Cannot save shipment.'));
             $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
         }
     }
     if ($isNeedCreateLabel) {
         $this->getResponse()->setBody($responseAjax->toJson());
     } else {
         $this->_redirect('*/sales_order/view', array('order_id' => $shipment->getOrderId()));
     }
 }
开发者ID:anumary,项目名称:test-magento,代码行数:66,代码来源:ShipmentController.php

示例2: ping

 /**
  * Tries to ping AvaTax service with provided credentials
  *
  * @param int $storeId
  * @return bool|array
  */
 public function ping($storeId = null)
 {
     /** @var OnePica_AvaTax_Model_Service_Avatax16_Config $config */
     $config = $this->getServiceConfig();
     $connection = $config->getTaxConnection();
     $result = null;
     $message = '';
     try {
         /** @var OnePica\AvaTax16\AddressResolution\PingResponse $result */
         $result = $connection->ping();
     } catch (Exception $exception) {
         $message = $exception->getMessage();
     }
     if (!isset($result) || !is_object($result) || !$result->getHasError()) {
         $actualResult = $result;
         $result = new Varien_Object();
         $result->setHasError($result->getHasError());
         $result->setActualResult($actualResult);
         $result->setMessage($message);
     }
     $this->_log(OnePica_AvaTax_Model_Source_Avatax_Logtype::PING, new stdClass(), $result, $storeId, $config->getParams());
     if ($result->getHasError()) {
         if (is_array($result->getErrors())) {
             $messages = array();
             foreach ($result->getErrors() as $messageItem) {
                 $messages[] = $this->__($messageItem);
             }
             $message .= implode(' ', $messages);
         }
     }
     if (!$message) {
         $message = $this->__('The user or account could not be authenticated.');
     }
     return !$result->getHasError() ? true : $message;
 }
开发者ID:onepica,项目名称:avatax,代码行数:41,代码来源:Ping.php

示例3: getLineCollection

 public function getLineCollection()
 {
     $maxCollectionSize = max(1, $this->mHelper('config')->getLogViewerMaxCollectionSize());
     $regExp = '/(\\d+-\\d+-\\d+T\\d+[0-9\\-+T:]+?)\\s+?([A-Z]+?)\\s+?\\((\\d+)\\)\\:\\s+?(.+?)(?:(?=(?:\\d+-\\d+-\\d+T\\d+[0-9\\-+T:]+?))|$)/si';
     $contents = file_get_contents($this->getPath());
     $lines = array();
     if (preg_match_all($regExp, $contents, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $lines[] = $match[0];
         }
     }
     $lines = array_reverse($lines);
     $collection = Mage::getModel('ewcore/system_log_file_line_collection');
     foreach ($lines as $line) {
         if ($collection->count() >= $maxCollectionSize) {
             break;
         }
         $line = trim($line);
         if (preg_match($regExp, $line, $match)) {
             list($date, $priorityName, $priority, $message) = array_slice($match, 1);
             $message = trim($message);
             if ($date and $priorityName and $priority and $message) {
                 $item = new Varien_Object();
                 $item->setDate($date);
                 $item->setPriorityName($priorityName);
                 $item->setPriority($priority);
                 $item->setMessage($message);
                 $collection->addItem($item);
             }
         }
     }
     return $collection;
 }
开发者ID:platonicsolution,项目名称:local-server,代码行数:33,代码来源:File.php

示例4: confirmAction

 public function confirmAction()
 {
     $updateResult = new Varien_Object();
     try {
         $orderItemId = (int) $this->getRequest()->getParam('item_id');
         $options = $this->getRequest()->getParam('options');
         $orderItem = Mage::getModel('sales/order_item')->load($orderItemId);
         $quote = Mage::getModel('sales/quote')->load($orderItem->getOrder()->getQuoteId());
         $quoteItem = Mage::getModel('sales/quote_item')->load($orderItem->getQuoteItemId())->setQuote($quote);
         $buyRequest = $orderItem->getBuyRequest();
         $buyRequest->setOptions($options);
         $products = $orderItem->getProduct()->getTypeInstance(true)->prepareForCartAdvanced($buyRequest, $orderItem->getProduct(), 'lite');
         $quoteItem->setOptions($products[0]->getCustomOptions());
         $quoteItem->setBuyRequest($buyRequest);
         $productOptions = $orderItem->getProductOptions();
         $productOptions['info_buyRequest'] = $buyRequest->getData();
         $productOptions['options'] = Mage::helper('catalog/product_configuration')->getCustomOptions($quoteItem);
         $orderItem->setProductOptions($productOptions);
         Mage::dispatchEvent('sales_convert_quote_item_to_order_item', array('order_item' => $orderItem, 'item' => $quoteItem));
         $quoteItem->save();
         $orderItem->save();
         $updateResult->setOk(true);
     } catch (Exception $e) {
         $updateResult->setError(true);
         $updateResult->setMessage($e->getMessage());
     }
     $updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname'));
     Mage::getSingleton('adminhtml/session')->setCompositeProductResult($updateResult);
     $this->_redirect('*/catalog_product/showUpdateResult');
     return $this;
 }
开发者ID:ftorresarr,项目名称:spacemariachi_customoptions,代码行数:31,代码来源:EditoptionsController.php

示例5: _prepareResponseObject

 /**
  * Return response object
  *
  * @return Varien_Object
  */
 protected function _prepareResponseObject()
 {
     $responseObject = new Varien_Object();
     $responseObject->setStatus(false);
     $responseObject->setResponse(null);
     $responseObject->setMessage(null);
     return $responseObject;
 }
开发者ID:Batname,项目名称:magento-js-components,代码行数:13,代码来源:CartController.php

示例6: testPaymentCapturedLifecyceEvent

 public function testPaymentCapturedLifecyceEvent()
 {
     $expectedValue = new Varien_Object();
     $expectedValue->setMessage('Captured Payment');
     $observer = $this->mockModel('deg_orderlifecycle/hooks', array('_dispatchEvent'));
     $observer->expects($this->any())->method('_dispatchEvent')->with('lifecycle_event', $expectedValue);
     $observerObject = new Varien_Event_Observer();
     $observer->paymentCaptureLifecyceEvent($observerObject);
 }
开发者ID:beejhuff,项目名称:magento-order-lifecycle,代码行数:9,代码来源:HooksTest.php

示例7: validateAction

 public function validateAction()
 {
     $response = new Varien_Object();
     $response->setError(false);
     $attributeCode = $this->getRequest()->getParam('attribute_code');
     $attributeId = $this->getRequest()->getParam('attribute_id');
     $attribute = Mage::getModel('catalog/entity_attribute')->loadByCode($this->_entityTypeId, $attributeCode);
     if ($attribute->getId() && !$attributeId) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('Attribute with the same code already exists'));
         $this->_initLayoutMessages('adminhtml/session');
         $response->setError(true);
         $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
     }
     $this->getResponse()->setBody($response->toJson());
 }
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:15,代码来源:ManageController.php

示例8: _prepareCollection

 protected function _prepareCollection()
 {
     $collection = new Varien_Data_Collection();
     $logs = explode("\n\n", $this->getJob()->getLog());
     foreach ($logs as $log) {
         @(list($date, $message) = explode("\t", $log, 2));
         if ($date and $message) {
             $object = new Varien_Object();
             $object->setCreatedAt($date);
             $object->setMessage($message);
             $collection->addItem($object);
         }
     }
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
开发者ID:platonicsolution,项目名称:local-server,代码行数:16,代码来源:Log.php

示例9: saveFormAction

 /**
  * Save grid edit form action
  *
  */
 public function saveFormAction()
 {
     $codeId = $this->getRequest()->getParam('code_id');
     $response = new Varien_Object();
     try {
         $model = Mage::getModel('find_feed/codes');
         if ($codeId) {
             $model->load($codeId);
         }
         $model->setImportCode($this->getRequest()->getParam('import_code'));
         $model->setEavCode($this->getRequest()->getParam('eav_code'));
         $model->setIsImported(intval($this->getRequest()->getParam('is_imported')));
         $model->save();
         $response->setError(0);
     } catch (Exception $e) {
         $response->setError(1);
         $response->setMessage('Save error');
     }
     $this->getResponse()->setBody($response->toJson());
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:24,代码来源:GridController.php

示例10: saveAction

 public function saveAction()
 {
     $this->_setTypeId();
     $response = new Varien_Object();
     $response->setError(0);
     $modelSet = Mage::getModel('eav/entity_attribute_set')->setId($this->getRequest()->getParam('id'))->setEntityTypeId(Mage::registry('entityType'));
     if ($this->getRequest()->getParam('gotoEdit')) {
         $modelSet = Mage::getModel('eav/entity_attribute_set');
         $modelSet->setAttributeSetName($this->getRequest()->getParam('attribute_set_name'))->setEntityTypeId(Mage::registry('entityType'));
     } else {
         $data = Zend_Json_Decoder::decode($this->getRequest()->getPost('data'));
         $modelSet->organizeData($data);
     }
     try {
         $modelSet->save();
         if ($this->getRequest()->getParam('gotoEdit') == 1) {
             $modelSet->initFromSkeleton($this->getRequest()->getParam('skeleton_set'))->save();
             $this->_redirect('*/*/edit', array('id' => $modelSet->getId()));
             $this->_getSession()->addSuccess($this->__('Attribute set successfully saved.'));
         } else {
             $this->_getSession()->addSuccess($this->__('Attribute set successfully saved.'));
             $response->setMessage(Mage::helper('catalog')->__('Attribute set successfully saved.'));
             $this->_redirect('*/*/');
         }
     } catch (Exception $e) {
         if ($this->getRequest()->getParam('gotoEdit') == 1) {
             $this->_getSession()->addError($this->__('Attribute set with the same name already exists.'));
             $this->_redirectReferer();
         } else {
             $this->_getSession()->addError($this->__('Attribute set with the same name already exists.'));
             $this->_initLayoutMessages('adminhtml/session');
             $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
             $response->setError(1);
         }
     }
     if ($this->getRequest()->getParam('gotoEdit') != 1) {
         $this->getResponse()->setBody($response->toJson());
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:39,代码来源:SetController.php

示例11: validateAction

 public function validateAction()
 {
     $response = new Varien_Object();
     $response->setError(false);
     if ($this->getRequest()->getPost()) {
         try {
             $pollModel = Mage::getModel('poll/poll');
             if (!$this->getRequest()->getParam('id')) {
                 $pollModel->setDatePosted(now());
             }
             if ($this->getRequest()->getParam('closed') && !$this->getRequest()->getParam('was_closed')) {
                 $pollModel->setDateClosed(now());
             }
             if (!$this->getRequest()->getParam('closed')) {
                 $pollModel->setDateClosed(new Zend_Db_Expr('null'));
             }
             $pollModel->setPollTitle($this->getRequest()->getParam('poll_title'))->setClosed($this->getRequest()->getParam('closed'));
             if ($this->getRequest()->getParam('id') > 0) {
                 $pollModel->setId($this->getRequest()->getParam('id'));
             }
             $stores = $this->getRequest()->getParam('store_ids');
             if (!is_array($stores) || count($stores) == 0) {
                 Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.'));
             }
             if (is_array($stores)) {
                 $storeIds = array();
                 foreach ($stores as $storeIdList) {
                     $storeIdList = explode(',', $storeIdList);
                     if (!$storeIdList) {
                         continue;
                     }
                     foreach ($storeIdList as $storeId) {
                         if ($storeId > 0) {
                             $storeIds[] = $storeId;
                         }
                     }
                 }
                 if (count($storeIds) === 0) {
                     Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.'));
                 }
                 $pollModel->setStoreIds($storeIds);
             }
             $answers = $this->getRequest()->getParam('answer');
             if (!is_array($answers) || sizeof($answers) == 0) {
                 Mage::throwException(Mage::helper('adminhtml')->__('Please, add some answers to this poll first.'));
             }
             if (is_array($answers)) {
                 $_titles = array();
                 foreach ($answers as $key => $answer) {
                     if (in_array($answer['title'], $_titles)) {
                         Mage::throwException(Mage::helper('adminhtml')->__('Your answers contain duplicates.'));
                     }
                     $_titles[] = $answer['title'];
                     $answerModel = Mage::getModel('poll/poll_answer');
                     if (intval($key) > 0) {
                         $answerModel->setId($key);
                     }
                     $answerModel->setAnswerTitle($answer['title'])->setVotesCount($answer['votes']);
                     $pollModel->addAnswer($answerModel);
                 }
             }
             $pollModel->save();
             Mage::register('current_poll_model', $pollModel);
             $answersDelete = $this->getRequest()->getParam('deleteAnswer');
             if (is_array($answersDelete)) {
                 foreach ($answersDelete as $answer) {
                     $answerModel = Mage::getModel('poll/poll_answer');
                     $answerModel->setId($answer)->delete();
                 }
             }
         } catch (Exception $e) {
             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
             $this->_initLayoutMessages('adminhtml/session');
             $response->setError(true);
             $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
         }
     }
     $this->getResponse()->setBody($response->toJson());
 }
开发者ID:quyip8818,项目名称:Mag,代码行数:79,代码来源:PollController.php

示例12: checkQuoteItemQty

 /**
  * Checking quote item quantity
  *
  * @param mixed $qty quantity of this item (item qty x parent item qty)
  * @param mixed $summaryQty quantity of this product in whole shopping cart which should be checked for stock availability
  * @param mixed $origQty original qty of item (not multiplied on parent item qty)
  * @return Varien_Object
  */
 public function checkQuoteItemQty($qty, $summaryQty, $origQty = 0)
 {
     $result = new Varien_Object();
     $result->setHasError(false);
     if (!is_numeric($qty)) {
         $qty = Mage::app()->getLocale()->getNumber($qty);
     }
     /**
      * Check quantity type
      */
     $result->setItemIsQtyDecimal($this->getIsQtyDecimal());
     if (!$this->getIsQtyDecimal()) {
         $result->setHasQtyOptionUpdate(true);
         $qty = intval($qty);
         /**
          * Adding stock data to quote item
          */
         $result->setItemQty($qty);
         if (!is_numeric($qty)) {
             $qty = Mage::app()->getLocale()->getNumber($qty);
         }
         $origQty = intval($origQty);
         $result->setOrigQty($origQty);
     }
     if ($this->getMinSaleQty() && $qty < $this->getMinSaleQty()) {
         $result->setHasError(true)->setMessage(Mage::helper('cataloginventory')->__('The minimum quantity allowed for purchase is %s.', $this->getMinSaleQty() * 1))->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in the requested quantity'))->setQuoteMessageIndex('qty');
         return $result;
     }
     if ($this->getMaxSaleQty() && $qty > $this->getMaxSaleQty()) {
         $result->setHasError(true)->setMessage(Mage::helper('cataloginventory')->__('The maximum quantity allowed for purchase is %s.', $this->getMaxSaleQty() * 1))->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products can not be ordered in requested quantity'))->setQuoteMessageIndex('qty');
         return $result;
     }
     if (!$this->getManageStock()) {
         return $result;
     }
     if (!$this->getIsInStock()) {
         $result->setHasError(true)->setMessage(Mage::helper('cataloginventory')->__('This product is currently out of stock.'))->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products are currently out of stock'))->setQuoteMessageIndex('stock');
         $result->setItemUseOldQty(true);
         return $result;
     }
     if (!$this->checkQty($summaryQty)) {
         $message = Mage::helper('cataloginventory')->__('The requested quantity for "%s" is not available.', $this->getProduct()->getName());
         $result->setHasError(true)->setMessage($message)->setQuoteMessage($message)->setQuoteMessageIndex('qty');
         return $result;
     } else {
         if ($this->getQty() - $summaryQty < 0) {
             if ($this->getProduct()) {
                 $backorderQty = $this->getQty() > 0 ? ($summaryQty - $this->getQty()) * 1 : $qty * 1;
                 if ($backorderQty > $qty) {
                     $backorderQty = $qty;
                 }
                 $result->setItemBackorders($backorderQty);
                 if ($this->getBackorders() == Mage_CatalogInventory_Model_Stock::BACKORDERS_YES_NOTIFY) {
                     $result->setMessage(Mage::helper('cataloginventory')->__('This product is not available in the requested quantity. %d of the items will be backordered.', $backorderQty, $this->getProduct()->getName()));
                 }
             }
         }
         // no return intentionally
     }
     return $result;
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:69,代码来源:Item.php

示例13: validateAction

 public function validateAction()
 {
     $response = new Varien_Object();
     $response->setError(false);
     try {
         /**
          * @todo implement full validation process with errors returning which are ignoring now
          */
     } catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
         $response->setError(true);
         $response->setAttribute($e->getAttributeCode());
         $response->setMessage($e->getMessage());
     } catch (Mage_Core_Exception $e) {
         $response->setError(true);
         $response->setMessage($e->getMessage());
     } catch (Exception $e) {
         $this->_getSession()->addError($e->getMessage());
         $this->_initLayoutMessages('adminhtml/session');
         $response->setError(true);
         $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
     }
     $this->getResponse()->setBody($response->toJson());
 }
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:23,代码来源:MagicslideshowController.php

示例14: promptAction

 /**
  * Submit prompt action
  *
  * @return  string
  */
 public function promptAction()
 {
     $params = $this->getRequest()->getParams();
     $response = new Varien_Object();
     try {
         $key = $params['id'];
         $data = $params['data'];
         if (empty($key) || empty($data)) {
             Mage::throwException('Parameters key and data are required');
         }
         if (!($prompt = $this->_loadPrompt($key))) {
             Mage::throwException('Session time out, try again');
         }
         $request = $this->_getRequestModel()->setRequest($prompt)->dispatch($data);
         $response->setStatus('OK');
         $response->setMessage($request->getMessage());
         $response->setType(MageHack_MageConsole_Model_Abstract::RESPONSE_TYPE_MESSAGE);
     } catch (Exception $e) {
         $response->setStatus('ERROR');
         $response->setType(MageHack_MageConsole_Model_Abstract::RESPONSE_TYPE_ERROR);
         $response->setMessage($e->getMessage());
     }
     $this->getResponse()->setHeader('Content-Type', 'application/json', true)->setBody($response->toJson());
 }
开发者ID:keywork,项目名称:MageConsole,代码行数:29,代码来源:MageconsoleController.php

示例15: jsonProductInfoAction

 public function jsonProductInfoAction()
 {
     $response = new Varien_Object();
     $id = $this->getRequest()->getParam('id');
     if (intval($id) > 0) {
         $product = Mage::getModel('catalog/product')->load($id);
         $response->setId($id);
         $response->addData($product->getData());
         $response->setError(0);
     } else {
         $response->setError(1);
         $response->setMessage(Mage::helper('catalog')->__('Unable to get the product ID.'));
     }
     $this->getResponse()->setBody($response->toJSON());
 }
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:15,代码来源:ReviewController.php


注:本文中的Varien_Object::setMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。