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


PHP Varien_Event_Observer::setData方法代码示例

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


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

示例1: setRowUrl

 /**
  * @test
  * @loadFixture ~FireGento_AdminMonitoring/default
  */
 public function setRowUrl()
 {
     $history = Mage::getModel('firegento_adminmonitoring/history')->load(8);
     $transport = new Varien_Object();
     $observer = new Varien_Event_Observer();
     $event = new Varien_Event();
     $event->setData('history', $history);
     $event->setData('transport', $transport);
     $observer->setEvent($event);
     $observer->setData('history', $history);
     $observer->setData('transport', $transport);
     $this->_model->setRowUrl($observer);
     $this->assertContains('sales_order/view/order_id/1/', $transport->getRowUrl());
 }
开发者ID:giuseppemorelli,项目名称:firegento-adminmonitoring,代码行数:18,代码来源:Order.php

示例2: sendOrderMail

function sendOrderMail($data)
{
    require_once '../app/Mage.php';
    Mage::app();
    if (isset($data['order_id']) && trim($data['order_id']) != '') {
        $order = Mage::getModel('sales/order')->loadByIncrementId(trim($data['order_id']));
        $orderId = $order->getId();
        if ($orderId) {
            $orderLoad = Mage::getModel('sales/order')->load($orderId);
            $orderLoad->sendNewOrderEmail();
            $proArr['message'] = "sent";
            $proArr['status'] = 'ok';
            $sms = new Celusion_SMSConneXion_Model_Observer();
            $observer = new Varien_Event_Observer();
            $observer->setData(array('order_ids' => array(0 => $orderId)));
            $sms->sendOrderAlerts($observer);
        } else {
            $proArr['message'] = "order_id doesnot match";
            $proArr['status'] = 'failed';
        }
    } else {
        $proArr['message'] = "order_id is required";
        $proArr['status'] = 'failed';
    }
    return $proArr;
}
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:26,代码来源:orderEmail.php

示例3: testCheckAvailableReorder

 public function testCheckAvailableReorder()
 {
     $orderMock = $this->mockModel('sales/order', array('load'));
     $id = 1;
     $incrementId = 10001;
     $orderMock->setId($id)->setData('increment_id', $incrementId);
     $orderMock->expects($this->any())->method('load')->will($this->returnValue($orderMock));
     $helperMock = $this->mockHelper('xcom_channelorder', array('isChannelOrder'));
     $helperMock->expects($this->once())->method('isChannelOrder')->will($this->returnValue(true));
     //mock request model for controller
     $requestMock = $this->getMock('stdClass', array('getParam', 'setParam'));
     $requestMock->expects($this->any())->method('getParam')->with($this->equalTo('order_id'))->will($this->returnValue($id));
     $requestMock->expects($this->any())->method('setParam')->with($this->equalTo('order_id'))->will($this->returnValue($id));
     //mock controller for observer
     $controllerMock = $this->getMock('stdClass', array('getRequest'));
     $controllerMock->expects($this->any())->method('getRequest')->will($this->returnValue($requestMock));
     $observer = new Varien_Event_Observer();
     $observer->setData('controller_action', $controllerMock);
     //process
     $this->_object->checkAvailableReorder($observer);
     /** @var $session Mage_Adminhtml_Model_Session_Quote */
     $session = Mage::getSingleton('adminhtml/session');
     $errors = $session->getMessages()->getErrors();
     //test errors count
     $countErrors = 1;
     $this->assertEquals($countErrors, count($errors));
     /** @var $error Mage_Core_Model_Message_Error */
     $error = $errors[0];
     $this->assertEquals('Order #' . $incrementId . ' cannot be reordered because it is from external marketplace.', $error->getText());
     //clean errors
     $session->getMessages(true);
     /**
      * Test skipping order which is not external
      */
     $helperMock = $this->mockHelper('xcom_channelorder', array('isChannelOrder'));
     $helperMock->expects($this->once())->method('isChannelOrder')->will($this->returnValue(false));
     //process
     $this->_object->checkAvailableReorder($observer);
     //test errors count
     $errors = $session->getMessages()->getErrors();
     $countErrors = 0;
     $this->assertEquals($countErrors, count($errors));
     //clean errors
     $session->getMessages(true);
     /**
      * Test skipping order which not found
      */
     $orderMock->setId(null);
     /**
      * Process
      * NOTE: Method Xcom_ChannelOrder_Helper_Data::isChannelOrder() must not run
      */
     $this->_object->checkAvailableReorder($observer);
     //test errors count
     $errors = $session->getMessages()->getErrors();
     $countErrors = 0;
     $this->assertEquals($countErrors, count($errors));
     //clean errors
     $session->getMessages(true);
 }
开发者ID:ridhoq,项目名称:mxpi-twitter,代码行数:60,代码来源:ObserverTest.php

示例4: buildObserver

 /**
  * Build correct observer structure
  *
  * @param $data array
  */
 protected function buildObserver(array $data)
 {
     $observer = new Varien_Event_Observer();
     $event = new Varien_Event();
     $event->setData($data);
     $data['event'] = $event;
     $observer->setData($data);
     return $observer;
 }
开发者ID:eniuz,项目名称:FrontendMonitoring,代码行数:14,代码来源:Observer.php

示例5: dispatchEvent

 /**
  * @see Mage_Core_Model_App::dispatchEvent($eventName, $args)
  */
 public function dispatchEvent($eventName, $args)
 {
     $event = new Varien_Event($args);
     $event->setName($eventName);
     $observer = new Varien_Event_Observer();
     $observer->setData(array('event' => $event));
     $observer->addData($args);
     $this->_bar->update($observer->getEvent());
     return parent::dispatchEvent($eventName, $args);
 }
开发者ID:nicolas-bastien,项目名称:MagentoUnderControl,代码行数:13,代码来源:App.php

示例6: dispatchEvent

 /**
  * @param $model string model syntax or class name (codex_module/observer or Codex_Module_Model_Observer)
  * @param $method string the exact method name (as defined in confix.xml)
  * @param $eventName string the original name of the event
  * @param array $args array
  */
 public static function dispatchEvent($model, $method, $eventName, array $args = array())
 {
     $event = new Varien_Event($args);
     $event->setName($eventName);
     $observer = new Varien_Event_Observer();
     $observer->setData(array('event' => $event));
     $observer->addData($args);
     $object = Mage::getModel($model);
     if (method_exists($object, $method)) {
         $object->{$method}($observer);
     }
 }
开发者ID:nhp,项目名称:Xtest,代码行数:18,代码来源:Xtest.php

示例7: dispatchEvent

 public function dispatchEvent($eventName, $args)
 {
     $eventName = strtolower($eventName);
     foreach ($this->_events as $area => $events) {
         if (!isset($events[$eventName])) {
             $eventConfig = $this->getConfig()->getEventConfig($area, $eventName);
             if (!$eventConfig) {
                 $this->_events[$area][$eventName] = false;
                 continue;
             }
             $observers = array();
             foreach ($eventConfig->observers->children() as $obsName => $obsConfig) {
                 $observers[$obsName] = array('type' => (string) $obsConfig->type, 'model' => $obsConfig->class ? (string) $obsConfig->class : $obsConfig->getClassName(), 'method' => (string) $obsConfig->method, 'args' => (array) $obsConfig->args);
             }
             $events[$eventName]['observers'] = $observers;
             $this->_events[$area][$eventName]['observers'] = $observers;
         }
         if (false === $events[$eventName]) {
             continue;
         } else {
             $event = new Varien_Event($args);
             $event->setName($eventName);
             $observer = new Varien_Event_Observer();
         }
         foreach ($events[$eventName]['observers'] as $obsName => $obs) {
             $observer->setData(array('event' => $event));
             Varien_Profiler::start('OBSERVER: ' . $obsName);
             switch ($obs['type']) {
                 case 'disabled':
                     break;
                 case 'object':
                 case 'model':
                     $method = $obs['method'];
                     $observer->addData($args);
                     $object = Mage::getModel($obs['model']);
                     $this->_callObserverMethod($object, $method, $observer);
                     break;
                 default:
                     $method = $obs['method'];
                     $observer->addData($args);
                     $object = Mage::getSingleton($obs['model']);
                     $this->_callObserverMethod($object, $method, $observer);
                     break;
             }
             Varien_Profiler::stop('OBSERVER: ' . $obsName);
         }
     }
     return $this;
 }
开发者ID:mswebdesign,项目名称:Mswebdesign_Magento_1_Community_Edition,代码行数:49,代码来源:App.php

示例8: prepareStockItemObserver

 private function prepareStockItemObserver(Mage_Catalog_Model_Product $product)
 {
     /** @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
     $stockItem = Mage::getModel('cataloginventory/stock_item');
     $stockItem->loadByProduct($product->getId())->setProductId($product->getId());
     foreach ($product->getData('stock_item')->getData() as $key => $value) {
         $stockItem->setOrigData($key, $value);
     }
     $observer = new Varien_Event_Observer();
     $observer->setEvent(new Varien_Event());
     $observer->setData('item', $stockItem);
     return $observer;
 }
开发者ID:giuseppemorelli,项目名称:magento-extension,代码行数:13,代码来源:ObjectChange.php

示例9: sendChangePasswordMail

function sendChangePasswordMail($data)
{
    include '../app/Mage.php';
    Mage::init();
    if (isset($data['user_id']) && trim($data['user_id']) != '' && isset($data['new_password']) && trim($data['new_password']) != '') {
        $customer = Mage::getModel('customer/customer')->load(trim($data['user_id']));
        if ($customer->getEmail()) {
            $templateId = 2;
            //template id for sending customer data
            $mailTemplate = Mage::getModel('core/email_template');
            $template_collection = $mailTemplate->load($templateId);
            $template_data = $template_collection->getData();
            $templateId = $template_data['template_id'];
            $mailSubject = $template_data['template_subject'];
            $from_email = Mage::getStoreConfig('trans_email/ident_sales/email');
            //fetch sender email
            $from_name = Mage::getStoreConfig('trans_email/ident_sales/name');
            //fetch sender name
            $sender = array('name' => 'msupply', 'email' => 'no-reply@msupply.com');
            $mailfirstname = $customer->getFirstname();
            $vars = array('newpassword' => trim($data['new_password']), 'firstname' => $mailfirstname);
            $email = $customer->getEmail();
            $storeId = Mage::app()->getStore()->getId();
            $model = $mailTemplate->setReplyTo($sender['email'])->setTemplateSubject($mailSubject);
            $model->sendTransactional($templateId, $sender, $email, 'msupply', $vars, $storeId);
            //sms
            $sms = new Celusion_SMSConneXion_Model_Observer();
            $observer = new Varien_Event_Observer();
            $observer->setData(array('customer' => $customer));
            $sms->sendUpdatePasswordAlertsApi($observer);
            $proArr['message'] = "sent";
            $proArr['status'] = 'ok';
        } else {
            $proArr['message'] = "user_id doesnot match";
            $proArr['status'] = 'failed';
        }
    } else {
        $proArr['message'] = "user_id and new_password is required";
        $proArr['status'] = 'failed';
    }
    return $proArr;
}
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:42,代码来源:customerMail.php

示例10: testPaymentMethodIsActive

 /**
  * @test
  * @loadFixture testPaymentMethodIsActive
  */
 public function testPaymentMethodIsActive()
 {
     $model = Mage::getModel('debit/debit');
     $checkResult = new StdClass();
     $checkResult->isAvailable = true;
     $observer = new Varien_Event_Observer();
     $event = new Varien_Event();
     $event->setData('method_instance', $model);
     $event->setData('result', $checkResult);
     $observer->setData('method_instance', $model);
     $observer->setData('result', $checkResult);
     $observer->setEvent($event);
     $this->_model->paymentMethodIsActive($observer);
     $this->assertTrue($observer->getEvent()->getResult()->isAvailable);
 }
开发者ID:pette87,项目名称:Magento-DebitPayment,代码行数:19,代码来源:Observer.php


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