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


PHP Varien_Event_Observer::getRequest方法代码示例

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


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

示例1: prepareCategorySave

 /**
  * Handling rule from the request when saving categories.
  *
  * @param Varien_Event_Observer $observer Event data.
  *
  * @return Smile_VirtualCategories_Model_Observer
  */
 public function prepareCategorySave(Varien_Event_Observer $observer)
 {
     $rule = $observer->getRequest()->getParam('rule', false);
     $category = $observer->getCategory();
     if ($rule !== false) {
         $ruleInstance = Mage::getModel('smile_virtualcategories/rule')->loadPost($rule);
         $category->setVirtualCategoryRule($ruleInstance);
         $positions = $observer->getRequest()->getParam('virtual_category_position', false);
         if ($positions !== false) {
             $category->setVirtualCategoryProductPositions($positions);
         }
     }
     return $this;
 }
开发者ID:manueltoniato,项目名称:smile-magento-elasticsearch,代码行数:21,代码来源:Observer.php

示例2: catalogProductPrepareSave

 public function catalogProductPrepareSave(Varien_Event_Observer $observer)
 {
     if ($observer->getRequest()->getModuleName() == 'ampgrid') {
         $date = $observer->getProduct()->getData('created_at');
         $observer->getProduct()->setData('created_at', strtotime($date));
     }
 }
开发者ID:rcclaudrey,项目名称:dev,代码行数:7,代码来源:Observer.php

示例3: onCheckoutCartAddProductComplete

 /**
  * Checks on adding a product to a cart if certain criteria are fulfilled
  * and redirect to the giveaway select page if so
  *
  * @param Varien_Event_Observer $oObserver
  */
 public function onCheckoutCartAddProductComplete(Varien_Event_Observer $oObserver)
 {
     /** @var $oHelper Sitewards_Giveaway_Helper_Data */
     $oHelper = Mage::helper('sitewards_giveaway');
     if ($oHelper->isExtensionEnabled() && $oHelper->isForwardToGiveawaysPageEnabled() && $oHelper->canAddGiveawaysToCart() !== false && !$oHelper->getGiveawayIdentifierValue($oObserver->getEvent()->getProduct()->getId())) {
         $oObserver->getRequest()->setParam('return_url', Mage::getUrl($oHelper->getGiveawaysPage()));
     }
 }
开发者ID:sitewards,项目名称:giveaway,代码行数:14,代码来源:Observer.php

示例4: calculateAdjustment

 public function calculateAdjustment(Varien_Event_Observer $observer)
 {
     $store = $observer->getStore();
     $request = $observer->getRequest();
     $allItems = $observer->getAllItems();
     $adjustments = $observer->getAdjustments();
     if (!$request->getFreeShipping()) {
         $itemAdjustments = $adjustments->getItems();
         $defaultAdjustment = Mage::helper('Lokey_PerItemShipping')->getDefaultAdjustment($store);
         foreach ($allItems as $item) {
             // Skip child items in main loop
             if ($item->getParentItem()) {
                 continue;
             }
             $qty = (double) ($item->getFreeShipping() === true ? 0 : $item->getQty() - $item->getFreeShipping());
             // Skip free shipping items
             if ($qty <= 0.0) {
                 continue;
             }
             $product = Mage::getModel('catalog/product')->setStoreId($store->getId())->load($item->getProductId());
             $adjustment = Mage::helper('Lokey_PerItemShipping')->getAdjustmentAmount($product, $defaultAdjustment);
             // Skip virtual products
             if ($product->getTypeInstance()->isVirtual()) {
                 continue;
             }
             if ($item->getHasChildren()) {
                 foreach ($item->getChildren() as $childItem) {
                     $childQty = (double) ($childItem->getFreeShipping() === true ? 0 : $childItem->getQty() - $childItem->getFreeShipping());
                     // Skip free shipping items
                     if ($childQty <= 0.0) {
                         continue;
                     }
                     $childProduct = Mage::getModel('catalog/product')->setStoreId($store->getId())->load($childItem->getProductId());
                     $childAdjustment = Mage::helper('Lokey_PerItemShipping')->getAdjustmentAmount($childProduct, $defaultAdjustment);
                     // Skip virtual products
                     if ($childProduct->getTypeInstance()->isVirtual()) {
                         continue;
                     }
                     if (Mage::helper('Lokey_PerItemShipping')->getUseQty($childProduct)) {
                         $adjustment += $childAdjustment * $childQty;
                     } else {
                         $adjustment += $childAdjustment;
                     }
                 }
             }
             if (!isset($itemAdjustments[$item->getId()])) {
                 $itemAdjustments[$item->getId()] = 0.0;
             }
             if (Mage::helper('Lokey_PerItemShipping')->getUseQty($product)) {
                 $itemAdjustments[$item->getId()] += $adjustment * $qty;
             } else {
                 $itemAdjustments[$item->getId()] += $adjustment;
             }
         }
         $adjustments->setItems($itemAdjustments);
     }
     return $this;
 }
开发者ID:xxorax,项目名称:Lokey_PerItemShipping,代码行数:58,代码来源:Observer.php

示例5: catalogCategoryPrepareSave

 /**
  * Append a custom block to the category.product.grid block.
  *
  * @param Varien_Event_Observer $observer
  * @return void
  */
 public function catalogCategoryPrepareSave(Varien_Event_Observer $observer)
 {
     $data = $observer->getRequest()->getParam('mep');
     $category = $observer->getCategory();
     $storeId = $observer->getRequest()->getParam('store');
     if (!empty($data) && $category->getId() && $storeId) {
         foreach ($data as $id => $value) {
             $id = ltrim($id, 'mapping_');
             $model = Mage::getModel('mep/attribute_mapping')->load($id);
             $model->load($id);
             try {
                 $model->setOption(array('value' => array($category->getId() => array($storeId => $value))));
                 $model->save();
             } catch (Exception $e) {
                 Mage::logException($e);
             }
         }
     }
 }
开发者ID:tschifftner,项目名称:Magento-MEP,代码行数:25,代码来源:Observer.php

示例6: addProductIdsToRequest

 public function addProductIdsToRequest(Varien_Event_Observer $observer)
 {
     if (Mage::app()->getRequest()->getControllerModule() === Mage::helper('autobuypromotions')->getControllerModule()) {
         $request = $observer->getRequest();
         $post = $request->getPost();
         if (isset($post['autobuyproduct_ids'])) {
             $productIds = $post['autobuyproduct_ids'];
             if ($productIds !== "") {
                 $productIds = explode('&', $productIds);
                 if (!empty($productIds)) {
                     $post['products'] = $productIds;
                 }
             }
         } elseif (isset($post['rule_id'])) {
             $post['products'] = Mage::getModel('salesrule/rule')->load($post['rule_id'])->getProductId();
         }
         if (isset($post['autobuytriggerproduct_ids'])) {
             $triggerProductIds = $post['autobuytriggerproduct_ids'];
             if ($triggerProductIds !== "") {
                 $triggerProductIds = explode('&', $triggerProductIds);
                 if (!empty($triggerProductIds)) {
                     $post['trigger_products'] = $triggerProductIds;
                 }
             }
         } elseif (isset($post['rule_id'])) {
             $post['trigger_products'] = Mage::getModel('salesrule/rule')->load($post['rule_id'])->getTriggerProductId();
         }
         $post['rule']['conditions'] = array('1' => array('type' => 'salesrule/rule_condition_combine', 'aggregator' => 'all', 'value' => '1', 'new_child' => null));
         if ($post['keywords'] !== "" || !empty($post['categorys'])) {
             $post['rule']['conditions']['1--1'] = array('type' => 'salesrule/rule_condition_product_subselect', 'attribute' => 'qty', 'operator' => '>=', 'value' => '1', 'aggregator' => 'all', 'new_child' => null);
             $this->_createConditionsFromFilters($post);
         } elseif (isset($post['trigger_products'])) {
             $post['rule']['conditions']['1--1'] = array('type' => 'salesrule/rule_condition_product_subselect', 'attribute' => 'qty', 'operator' => '>=', 'value' => '1', 'aggregator' => 'all', 'new_child' => null);
             $conditionsSkus = array();
             foreach ($post['trigger_products'] as $triggerProductId) {
                 $conditionsSkus[] = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($triggerProductId)->getSku();
             }
             $conditionSkusCsv = implode(', ', $conditionsSkus);
             $post['rule']['conditions']['1--1--1'] = array('type' => 'salesrule/rule_condition_product', 'attribute' => 'sku', 'operator' => '()', 'value' => $conditionSkusCsv);
         }
         $post['rule']['actions'] = array('1' => array('type' => 'salesrule/rule_condition_product_combine', 'aggregator' => 'all', 'value' => '1', 'new_child' => null));
         if (isset($post['products'])) {
             $actionsSkus = array();
             foreach ($post['products'] as $productId) {
                 $actionsSkus[] = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($productId)->getSku();
             }
             $actionSkusCsv = implode(', ', $actionsSkus);
             $post['rule']['actions']['1--1'] = array('type' => 'salesrule/rule_condition_product', 'attribute' => 'sku', 'operator' => '()', 'value' => $actionSkusCsv);
         }
         $request->setPost($post);
     }
 }
开发者ID:outeredge,项目名称:edge-magento-module-autobuypromotions,代码行数:52,代码来源:Observer.php

示例7: prepareCustomerBalanceSave

 /**
  * Prepare customer balance POST data
  *
  * @param Varien_Event_Observer $observer
  */
 public function prepareCustomerBalanceSave($observer)
 {
     if (!Mage::helper('enterprise_customerbalance')->isEnabled()) {
         return;
     }
     /* @var $customer Mage_Customer_Model_Customer */
     $customer = $observer->getCustomer();
     /* @var $request Mage_Core_Controller_Request_Http */
     $request = $observer->getRequest();
     if ($data = $request->getPost('customerbalance')) {
         $customer->setCustomerBalanceData($data);
     }
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:18,代码来源:Observer.php

示例8: adminhtmlControllerSalesrulePrepareSave

 /**
  * Check if the given free product SKU is not empty and references a valid product.
  *
  * @param Varien_Event_Observer $observer
  *
  * @throws Mage_Core_Exception
  */
 public function adminhtmlControllerSalesrulePrepareSave($observer)
 {
     $request = $observer->getRequest();
     if ($request->getParam('simple_action') == C4B_Freeproduct_Model_Consts::ADD_GIFT_ACTION) {
         $giftSku = $request->getParam('gift_sku');
         if (empty($giftSku) || Mage::getModel('catalog/product')->getIdBySku($giftSku) == false) {
             // make sure that unsaved data is not lost
             $data = $request->getPost();
             Mage::getSingleton('adminhtml/session')->setPageData($data);
             // just throw an exception, Mage_Adminhtml_Promo_QuoteController::saveAction will do the rest
             throw new Mage_Core_Exception('The free product SKU must be a valid product.');
         }
     }
 }
开发者ID:MaWoScha,项目名称:C4B_Freeproduct,代码行数:21,代码来源:Observer.php

示例9: calculateAdjustment

 public function calculateAdjustment(Varien_Event_Observer $observer)
 {
     $store = $observer->getStore();
     $request = $observer->getRequest();
     $allItems = $observer->getAllItems();
     $adjustments = $observer->getAdjustments();
     $groupAdjustments = array();
     $itemAdjustments = $adjustments->getItems();
     foreach ($allItems as $item) {
         $qty = $item->getQty();
         if ($item->getParentItem()) {
             $qty *= $item->getParentItem()->getQty();
         }
         $qty -= $item->getFreeShipping();
         $qty = max($qty, 0);
         if ($request->getFreeShipping() || $qty === 0) {
             continue;
         }
         $product = Mage::getModel('catalog/product')->setStoreId($store->getId())->load($item->getProductId());
         $group = Mage::helper('Lokey_PerGroupShipping/Data')->getAdjustmentGroupByProduct($product);
         if (!$product->getTypeInstance()->isVirtual() && $group->getId()) {
             $adjustment = max(round($group->getAmount(), 2), 0.0);
             switch ($group->getType()) {
                 case Lokey_PerGroupShipping_Model_System_Config_Source_AdjustmentType::ORDER:
                     $groupAdjustments[$group->getId()] = $adjustment;
                     break;
                 case Lokey_PerGroupShipping_Model_System_Config_Source_AdjustmentType::LINE:
                     if (!isset($itemAdjustments[$item->getId()])) {
                         $itemAdjustments[$item->getId()] = 0.0;
                     }
                     $itemAdjustments[$item->getId()] += $adjustment;
                     break;
                 case Lokey_PerGroupShipping_Model_System_Config_Source_AdjustmentType::UNIT:
                 default:
                     if (!isset($itemAdjustments[$item->getId()])) {
                         $itemAdjustments[$item->getId()] = 0.0;
                     }
                     $itemAdjustments[$item->getId()] += $adjustment * $qty;
                     break;
             }
         }
     }
     foreach ($groupAdjustments as $groupAdjustment) {
         $adjustments->setOrder($adjustments->getOrder() + $groupAdjustment);
     }
     $adjustments->setItems($itemAdjustments);
     return $this;
 }
开发者ID:xxorax,项目名称:Lokey_PerGroupShipping,代码行数:48,代码来源:Observer.php

示例10: addToCartComplete

 public function addToCartComplete(Varien_Event_Observer $observer)
 {
     if ($observer->getRequest()->getParam('return_url') || !Mage::getStoreConfig('suggestpage/general/show_after_addtocart')) {
         return;
     }
     if ($this->_isMobile() && !Mage::getStoreConfig('suggestpage/mobile/show_after_addtocart')) {
         return;
     }
     $observer->getResponse()->setRedirect(Mage::getUrl('suggest'));
     $session = Mage::getSingleton('checkout/session');
     $session->setNoCartRedirect(true);
     $session->setSuggestpageProductId($observer->getProduct()->getId());
     $session->setViewCartUrl(Mage::getUrl('suggest'));
     //ajaxpro integration
     $message = Mage::helper('checkout')->__('%s was added to your shopping cart.', Mage::helper('core')->htmlEscape($observer->getProduct()->getName()));
     $session->addSuccess($message);
 }
开发者ID:santhosh400,项目名称:ecart,代码行数:17,代码来源:Observer.php

示例11: saveCategoryTop

 public function saveCategoryTop(Varien_Event_Observer $observer)
 {
     $dat = $observer->getRequest()->getParams();
     $categoryId = $observer->getCategory()->getId();
     $read = Mage::getSingleton('core/resource')->getConnection('core_read');
     $data['category_id'] = $categoryId;
     if (@$dat['active_product']) {
         $data['active_product'] = @$dat['active_product'];
     } else {
         $data['active_product'] = 0;
     }
     $data['numbers_product'] = @$dat['numbers_product'];
     if (@$dat['active_width']) {
         $data['active_width'] = @$dat['active_width'];
     } else {
         $data['active_width'] = 0;
     }
     $data['width_level'] = @$dat['width_level'];
     if (@$dat['active_static_block_top']) {
         $data['active_static_block_top'] = @$dat['active_static_block_top'];
     } else {
         $data['active_static_block_top'] = 0;
     }
     $data['static_block_top'] = @$dat['static_block_top'];
     if (@$dat['active_static_block']) {
         $data['active_static_block'] = $dat['active_static_block'];
     } else {
         $data['active_static_block'] = 0;
     }
     if (@$dat['active_static_block_left']) {
         $data['active_static_block_left'] = @$dat['active_static_block_left'];
     } else {
         $data['active_static_block_left'] = 0;
     }
     $data['static_block_left'] = @$dat['static_block_left'];
     if (@$dat['active_static_block_bottom']) {
         $data['active_static_block_bottom'] = @$dat['active_static_block_bottom'];
     } else {
         $data['active_static_block_bottom'] = 0;
     }
     $data['static_block_bottom'] = @$dat['static_block_bottom'];
     if (@$dat['active_static_block_right']) {
         $data['active_static_block_right'] = @$dat['active_static_block_right'];
     } else {
         $data['active_static_block_right'] = 0;
     }
     $data['static_block_right'] = @$dat['static_block_right'];
     if (@$dat['active_label']) {
         $data['active_label'] = @$dat['active_label'];
     } else {
         $data['active_label'] = 0;
     }
     $data['label'] = @$dat['label'];
     if (@$dat['active_thumbail']) {
         $data['active_thumbail'] = @$dat['active_thumbail'];
     } else {
         $data['active_thumbail'] = 0;
     }
     $data['level_column_count'] = @$dat['level_column_count'];
     if (@$dat['hidden_menutop']) {
         $data['hidden_menutop'] = @$dat['hidden_menutop'];
     } else {
         $data['hidden_menutop'] = 0;
     }
     if (@$dat['category_children']) {
         $data['category_children'] = @$dat['category_children'];
     } else {
         $data['category_children'] = 0;
     }
     if (@$dat['width_block_left']) {
         $data['width_block_left'] = @$dat['width_block_left'];
     } else {
         $data['width_block_left'] = 0;
     }
     if (@$dat['width_block_right']) {
         $data['width_block_right'] = @$dat['width_block_right'];
     } else {
         $data['width_block_right'] = 0;
     }
     if (@$dat['width_children']) {
         $data['width_children'] = @$dat['width_children'];
     } else {
         $data['width_children'] = 0;
     }
     if (@$dat['font-color']) {
         $data['font-color'] = @$dat['font-color'];
     } else {
         $data['font-color'] = '';
     }
     if (@$dat['background-color']) {
         $data['background-color'] = @$dat['background-color'];
     } else {
         $data['background-color'] = '';
     }
     if (@$dat['hide_menutop']) {
         $data['hide_menutop'] = @$dat['hide_menutop'];
     } else {
         $data['hide_menutop'] = 0;
     }
     $model = Mage::getModel('megamenu/megamenu');
//.........这里部分代码省略.........
开发者ID:novayadi85,项目名称:navicet,代码行数:101,代码来源:Observer.php

示例12: makerCustomerChangeAfter

 /**
  * When customer is modified change the maker type accordingly to approver
  * and if maker himself moved to general disable maker.
  *
  * @param unknown $observer            
  */
 public function makerCustomerChangeAfter(Varien_Event_Observer $observer)
 {
     if (self::$_observerExecutionCounter > 1) {
         return $this;
     }
     self::$_observerExecutionCounter++;
     $customer = $observer->getCustomer();
     $request = $observer->getRequest();
     $customer_id = $customer->getId();
     $is_approver = $customer->getIsApprover();
     $has_approver = $customer->getZmyapprover();
     $mcActive = (int) $customer->getAttribute('maker_status')->getSource()->getOptionId('active');
     $approver_cust_type = (int) $customer->getZiscorporate();
     // customer
     // type
     $general_cust_type = (int) $customer->getAttribute('ziscorporate')->getSource()->getOptionId('general');
     // db connection establishment
     // $resource = Mage::getSingleton ( 'core/resource' );
     // $writeConnection = $resource->getConnection ( 'core_write' );
     // $readConnection = $resource->getConnection ( 'core_read' );
     // if approver
     if ($is_approver) {
         // if the customer is an approver
         $makers = Mage::getResourceModel('customer/customer_collection')->addAttributeToFilter('zmyapprover', $customer_id)->addAttributeToFilter('maker_status', $mcActive)->addAttributeToSelect('*')->addNameToSelect();
         // if bussiness, corporate, credit user
         if ($approver_cust_type == 816 || $approver_cust_type == 814 || $approver_cust_type == 470 || $approver_cust_type == 815) {
             foreach ($makers as $maker) {
                 $maker->setData('ziscorporate', $approver_cust_type);
                 try {
                     $maker->getResource()->saveAttribute($maker, 'ziscorporate');
                 } catch (Exception $e) {
                     Mage::log($e->getMessage(), null, 'mclog.log');
                 }
             }
         } else {
             foreach ($makers as $maker) {
                 $maker->setData('ziscorporate', $general_cust_type);
                 $maker->setData('maker_status', 0);
                 $maker->setData('zmyapprover', '');
                 try {
                     $maker->getResource()->saveAttribute($maker, 'maker_status');
                     $maker->getResource()->saveAttribute($maker, 'ziscorporate');
                     $maker->getResource()->saveAttribute($maker, 'zmyapprover');
                 } catch (Exception $e) {
                     Mage::log($e->getMessage(), null, 'mclog.log');
                 }
             }
         }
         // if approver cutomer type is general send mail to all makers
         if ($approver_cust_type != 816 && $approver_cust_type != 814 && $approver_cust_type != 470 && $approver_cust_type != 815) {
             // disabling the approver privileg on customer moved to personel
             $customer->setData('is_approver', 0);
             // set approver status
             // to no
             try {
                 $customer->getResource()->saveAttribute($customer, 'is_approver');
                 // save
                 // customer
                 // attribute
             } catch (Exception $e) {
                 Mage::log($e->getMessage(), null, 'mclog.log');
             }
             $customer->setData('is_approver', 0);
             // set approver status
             // to no
             try {
                 $customer->getResource()->saveAttribute($customer, 'is_approver');
                 // save
                 // customer
                 // attribute
             } catch (Exception $e) {
                 Mage::log($e->getMessage(), null, 'mclog.log');
             }
             $email_template = Mage::getModel('core/email_template');
             $templateId = Mage::getModel('core/email_template')->loadByCode(self::EMAIL_TEMPLATE_XML_PATH_MC1)->getId();
             // get
             // template
             // email
             // id
             // by
             // code
             // $maker_emails
             // =
             // array();
             foreach ($makers as $maker) {
                 // send mails to all the makers
                 // of the approver
                 $mail_vars = array('approver' => $customer, 'maker' => $maker);
                 // send mail
                 $email_template->sendTransactional($templateId, 'sales', $maker->getEmail(), $maker->getName(), $mail_vars);
             }
         }
     }
     // if a maker changes his/her customer type.
//.........这里部分代码省略.........
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:101,代码来源:Observer.php

示例13: catalogCategoryPrepareSave

 /**
  * @param Varien_Event_Observer $observer
  */
 public function catalogCategoryPrepareSave(Varien_Event_Observer $observer)
 {
     /** @var Mage_Catalog_Model_Category $category */
     $category = $observer->getCategory();
     if ($this->_shouldPublishCategory()) {
         if ($category->getId()) {
             $changesObject = Mage::helper('firegento_flexcms')->getChangesObject($category);
             if ($changesObject->getId()) {
                 $changesObject->delete();
             }
         }
         return;
     }
     /** @var Mage_Core_Controller_Request_Http $request */
     $request = $observer->getRequest();
     if ($category->getId()) {
         /** @var $changesObject Firegento_FlexCms_Model_Category_Changes */
         $changesObject = Mage::helper('firegento_flexcms')->getChangesObject($category);
         if (!$changesObject->getId()) {
             $changesObject->setCategoryId($category->getId());
             $changesObject->setStoreId($category->getStoreId());
         }
         $changes = array();
         foreach ($category->getData() as $key => $value) {
             if (in_array($key, array('id', 'path_ids'))) {
                 continue;
             }
             $origValue = $category->getOrigData($key);
             if ($this->_isUsingDefaultValue($request, $key)) {
                 $value = $category->getResource()->getAttributeRawValue($category->getId(), $key, 0);
             }
             if ($origValue != $value || is_null($origValue) && $value) {
                 $changes[$key] = $value;
                 if (is_null($origValue)) {
                     $category->setData($key, false);
                 } else {
                     $category->setData($key, $origValue);
                 }
             }
         }
         if (sizeof($changes)) {
             $changesObject->setAdminUserId($this->_getAdminUserId());
             $changesObject->setChanges($changes)->save();
         } else {
             if ($changesObject->getId()) {
                 $changesObject->delete();
             }
         }
     } else {
         if ($category->getIsActive()) {
             $category->setIsActive(false);
             $category->setIsDraft(true);
             $category->setOriginalIsActive(true);
         }
     }
 }
开发者ID:OurLaborisJoy,项目名称:FireGento_FlexCms,代码行数:59,代码来源:Observer.php

示例14: productPrepareSave

 /**
  * Saves the form data added to the product catalog
  *
  * @param Varien_Event_Observer $observer
  * @return boolean
  */
 public function productPrepareSave($observer)
 {
     $request = $observer->getRequest();
     $product = $observer->getProduct();
     if (!$product->getId()) {
         return false;
     }
     $storeId = $request->getParam('store', 0);
     $formData = array('active', 'period', 'content', 'adjustment', 'message', 'multiply_by_qty', 'period_type', 'send_limit');
     foreach ($this->_singleton->getSupportedTypes() as $type) {
         if (!$this->_helper->isPostEnabled($type)) {
             continue;
         }
         try {
             $post = Mage::getModel('bronto_reviews/post_purchase')->loadByProduct($product->getId(), $type, $storeId);
             // Is set and true, delete if applicable
             if ($request->getParam("{$type}_use_default", false)) {
                 if ($post->getId()) {
                     $post->delete();
                 }
                 continue;
             }
             foreach ($formData as $field) {
                 $requestKey = "{$type}_{$field}";
                 $requestOverride = "{$type}_{$field}_override";
                 if ($request->has($requestKey)) {
                     $post->setData($field, $request->getParam($requestKey));
                 }
                 if ($request->getParam($requestOverride) == 'default') {
                     $post->setData($field, null);
                 }
             }
             // This means the form wasn't loaded
             if (is_null($post->getActive())) {
                 continue;
             }
             $post->save();
         } catch (Exception $e) {
             $this->_helper->writeError("Failed to save post-purchase info: {$e->getMessage()}");
         }
     }
     return true;
 }
开发者ID:bevello,项目名称:bevello,代码行数:49,代码来源:Observer.php

示例15: deliveryAtToQuote

 public function deliveryAtToQuote(Varien_Event_Observer $observer)
 {
     $observer->getQuote()->setDeliveryAt($observer->getRequest()->getPost('delivery_at'));
 }
开发者ID:swnsma,项目名称:practice,代码行数:4,代码来源:Observer.php


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