本文整理汇总了PHP中AO::dispatchEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP AO::dispatchEvent方法的具体用法?PHP AO::dispatchEvent怎么用?PHP AO::dispatchEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AO
的用法示例。
在下文中一共展示了AO::dispatchEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendAction
public function sendAction()
{
$product = $this->_initProduct();
$this->_initSendToFriendModel();
if (!$product || !$product->isVisibleInCatalog()) {
$this->_forward('noRoute');
return;
}
$productHelper = AO::helper('catalog/product');
$sendToFriendModel = AO::registry('send_to_friend_model');
/**
* check if user is allowed to send product to a friend
*/
if (!$sendToFriendModel->canEmailToFriend()) {
AO::getSingleton('catalog/session')->addError($this->__('You cannot email this product to a friend'));
$this->_redirectReferer($product->getProductUrl());
return;
}
$maxSendsToFriend = $sendToFriendModel->getMaxSendsToFriend();
if ($maxSendsToFriend) {
AO::getSingleton('catalog/session')->addNotice($this->__('You cannot send more than %d times in an hour', $maxSendsToFriend));
}
$this->loadLayout();
$this->_initLayoutMessages('catalog/session');
$this->renderLayout();
AO::dispatchEvent('sendfriend_product', array('product' => $product));
}
示例2: getJsonConfig
public function getJsonConfig()
{
AO::app()->getLocale()->getJsPriceFormat();
$store = AO::app()->getStore();
$optionsArray = $this->getOptions();
$options = array();
$selected = array();
foreach ($optionsArray as $_option) {
if (!$_option->getSelections()) {
continue;
}
$option = array('selections' => array(), 'isMulti' => $_option->getType() == 'multi' || $_option->getType() == 'checkbox');
$selectionCount = count($_option->getSelections());
foreach ($_option->getSelections() as $_selection) {
$_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1;
$selection = array('qty' => $_qty, 'customQty' => $_selection->getSelectionCanChangeQty(), 'price' => AO::helper('core')->currency($_selection->getFinalPrice(), false, false), 'priceValue' => AO::helper('core')->currency($_selection->getSelectionPriceValue(), false, false), 'priceType' => $_selection->getSelectionPriceType(), 'tierPrice' => $_selection->getTierPrice(), 'plusDisposition' => 0, 'minusDisposition' => 0);
$responseObject = new Varien_Object();
$args = array('response_object' => $responseObject, 'selection' => $_selection);
AO::dispatchEvent('bundle_product_view_config', $args);
if (is_array($responseObject->getAdditionalOptions())) {
foreach ($responseObject->getAdditionalOptions() as $o => $v) {
$selection[$o] = $v;
}
}
$option['selections'][$_selection->getSelectionId()] = $selection;
if (($_selection->getIsDefault() || $selectionCount == 1 && $_option->getRequired()) && $_selection->isSalable()) {
$selected[$_option->getId()][] = $_selection->getSelectionId();
}
}
$options[$_option->getId()] = $option;
}
$config = array('options' => $options, 'selected' => $selected, 'bundleId' => $this->getProduct()->getId(), 'priceFormat' => AO::app()->getLocale()->getJsPriceFormat(), 'basePrice' => AO::helper('core')->currency($this->getProduct()->getPrice(), false, false), 'priceType' => $this->getProduct()->getPriceType(), 'specialPrice' => $this->getProduct()->getSpecialPrice());
return Zend_Json::encode($config);
}
示例3: _initProduct
/**
* Initialize and check product
*
* @return Mage_Catalog_Model_Product
*/
protected function _initProduct()
{
AO::dispatchEvent('review_controller_product_init_before', array('controller_action' => $this));
$categoryId = (int) $this->getRequest()->getParam('category', false);
$productId = (int) $this->getRequest()->getParam('id');
if (!$productId) {
return false;
}
$product = AO::getModel('catalog/product')->setStoreId(AO::app()->getStore()->getId())->load($productId);
/* @var $product Mage_Catalog_Model_Product */
if (!$product->getId() || !$product->isVisibleInCatalog() || !$product->isVisibleInSiteVisibility()) {
return false;
}
if ($categoryId) {
$category = AO::getModel('catalog/category')->load($categoryId);
AO::register('current_category', $category);
}
AO::register('current_product', $product);
AO::register('product', $product);
try {
AO::dispatchEvent('review_controller_product_init', array('product' => $product));
AO::dispatchEvent('review_controller_product_init_after', array('product' => $product, 'controller_action' => $this));
} catch (Mage_Core_Exception $e) {
AO::logException($e);
return false;
}
return $product;
}
示例4: clean
/**
* Clean logs
*
* @param Mage_Log_Model_Log $object
* @return Mage_Log_Model_Mysql4_Log
*/
public function clean(Mage_Log_Model_Log $object)
{
$cleanTime = $object->getLogCleanTime();
AO::dispatchEvent('log_log_clean_before', array('log' => $object));
$this->_cleanVisitors($cleanTime);
$this->_cleanCustomers($cleanTime);
$this->_cleanUrls();
AO::dispatchEvent('log_log_clean_after', array('log' => $object));
return $this;
}
示例5: _getAdditionalElementTypes
protected function _getAdditionalElementTypes()
{
$result = array('price' => AO::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'), 'image' => AO::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'), 'boolean' => AO::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean'));
$response = new Varien_Object();
$response->setTypes(array());
AO::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response' => $response));
foreach ($response->getTypes() as $typeName => $typeClass) {
$result[$typeName] = $typeClass;
}
return $result;
}
示例6: authenticate
/**
* Authenticate customer
*
* @param string $login
* @param string $password
* @return true
* @throws Exception
*/
public function authenticate($login, $password)
{
$this->loadByEmail($login);
if ($this->getConfirmation() && $this->isConfirmationRequired()) {
throw new Exception(AO::helper('customer')->__('This account is not confirmed.'), self::EXCEPTION_EMAIL_NOT_CONFIRMED);
}
if (!$this->validatePassword($password)) {
throw new Exception(AO::helper('customer')->__('Invalid login or password.'), self::EXCEPTION_INVALID_EMAIL_OR_PASSWORD);
}
AO::dispatchEvent('customer_customer_authenticated', array('model' => $this, 'password' => $password));
return true;
}
示例7: addProducts
/**
* Add products to websites
*
* @param array $websiteIds
* @param array $productIds
* @return Mage_Catalog_Model_Product_Website
*/
public function addProducts($websiteIds, $productIds)
{
try {
$this->_getResource()->addProducts($websiteIds, $productIds);
$this->_refreshRewrites($productIds);
AO::getResourceModel('catalog/category')->refreshProductIndex(array(), $productIds);
AO::dispatchEvent('catalog_product_website_update', array('website_ids' => $websiteIds, 'product_ids' => $productIds, 'action' => 'add'));
} catch (Exception $e) {
AO::throwException(AO::helper('catalog')->__('There was an error while adding products to websites'));
}
return $this;
}
示例8: getFinalPrice
/**
* Get product final price
*
* @param double $qty
* @param Mage_Catalog_Model_Product $product
* @return double
*/
public function getFinalPrice($qty = null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
$finalPrice = $product->getPrice();
/**
* Just product with fixed price calculation has price
*/
if ($finalPrice) {
$finalPrice = $this->_applyTierPrice($product, $qty, $finalPrice);
$finalPrice = $this->_applySpecialPrice($product, $finalPrice);
$product->setFinalPrice($finalPrice);
AO::dispatchEvent('catalog_product_get_final_price', array('product' => $product));
$finalPrice = $product->getData('final_price');
}
if ($product->hasCustomOptions()) {
$customOption = $product->getCustomOption('bundle_option_ids');
// $optionIds = unserialize($customOption->getValue());
$customOption = $product->getCustomOption('bundle_selection_ids');
$selectionIds = unserialize($customOption->getValue());
$selections = $product->getTypeInstance(true)->getSelectionsByIds($selectionIds, $product);
foreach ($selections->getItems() as $selection) {
if ($selection->isSalable()) {
$selectionQty = $product->getCustomOption('selection_qty_' . $selection->getSelectionId());
if ($selectionQty) {
$finalPrice = $finalPrice + $this->getSelectionPrice($product, $selection, $selectionQty->getValue());
}
}
}
} else {
// if ($options = $this->getOptions($product)) {
// /* some strange thing
// foreach ($options as $option) {
// $selectionCount = count($option->getSelections());
// if ($selectionCount) {
// foreach ($option->getSelections() as $selection) {
// if ($selection->isSalable() && ($selection->getIsDefault() || ($option->getRequired() &&)) {
// $finalPrice = $finalPrice + $this->getSelectionPrice($product, $selection);
// }
// }
// }
// }
// */
// }
}
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
$product->setFinalPrice($finalPrice);
return max(0, $product->getData('final_price'));
}
示例9: getFinalPrice
/**
* Get product final price
*
* @param double $qty
* @param Mage_Catalog_Model_Product $product
* @return double
*/
public function getFinalPrice($qty = null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
$finalPrice = $product->getPrice();
$finalPrice = $this->_applyTierPrice($product, $qty, $finalPrice);
$finalPrice = $this->_applySpecialPrice($product, $finalPrice);
$product->setFinalPrice($finalPrice);
AO::dispatchEvent('catalog_product_get_final_price', array('product' => $product));
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
return max(0, $finalPrice);
}
示例10: start
/**
* Conigure and start session
*
* @param string $sessionName
* @return Mage_Core_Model_Session_Abstract_Varien
*/
public function start($sessionName = null)
{
if (isset($_SESSION)) {
return $this;
}
if (VPROF) {
Varien_Profiler::start(__METHOD__ . '/setOptions');
}
if (is_writable(AO::getBaseDir('session'))) {
session_save_path($this->getSessionSavePath());
}
if (VPROF) {
Varien_Profiler::stop(__METHOD__ . '/setOptions');
}
switch ($this->getSessionSaveMethod()) {
case 'db':
ini_set('session.save_handler', 'user');
$sessionResource = AO::getResourceSingleton('core/session');
/* @var $sessionResource Mage_Core_Model_Mysql4_Session */
$sessionResource->setSaveHandler();
break;
case 'memcache':
ini_set('session.save_handler', 'memcache');
session_save_path($this->getSessionSavePath());
break;
default:
session_module_name('files');
break;
}
AO::dispatchEvent('core_session_before_set_cookie_params');
// set session cookie params
session_set_cookie_params($this->getCookie()->getLifetime(), $this->getCookie()->getPath(), $this->getCookie()->getDomain(), $this->getCookie()->isSecure(), $this->getCookie()->getHttponly());
if (!empty($sessionName)) {
session_name($sessionName);
}
// potential custom logic for session id (ex. switching between hosts)
$this->setSessionId();
if (VPROF) {
Varien_Profiler::start(__METHOD__ . '/start');
}
if ($sessionCacheLimiter = AO::getConfig()->getNode('global/session_cache_limiter')) {
session_cache_limiter((string) $sessionCacheLimiter);
}
session_start();
if (VPROF) {
Varien_Profiler::stop(__METHOD__ . '/start');
}
return $this;
}
示例11: _prepareForm
protected function _prepareForm()
{
$this->setFormExcludedFieldList(array('tier_price', 'gallery', 'media_gallery'));
AO::dispatchEvent('adminhtml_catalog_product_form_prepare_excluded_field_list', array('object' => $this));
$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('fields', array('legend' => AO::helper('catalog')->__('Attributes')));
$attributes = $this->getAttributes();
/**
* Initialize product object as form property
* for using it in elements generation
*/
$form->setDataObject(AO::getModel('catalog/product'));
$this->_setFieldset($attributes, $fieldset, $this->getFormExcludedFieldList());
$form->setFieldNameSuffix('attributes');
$this->setForm($form);
}
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:16,代码来源:Catalog_Product_Edit_Action_Attribute_Tab_Attributes.php
示例12: toQuote
/**
* Converting order object to quote object
*
* @param Mage_Sales_Model_Order $order
* @return Mage_Sales_Model_Quote
*/
public function toQuote(Mage_Sales_Model_Order $order, $quote = null)
{
if (!$quote instanceof Mage_Sales_Model_Quote) {
$quote = AO::getModel('sales/quote');
}
$quote->setStoreId($order->getStoreId())->setOrderId($order->getId());
AO::helper('core')->copyFieldset('sales_convert_order', 'to_quote', $order, $quote);
// /**
// * Customer data
// */
// ->setCustomerId($order->getCustomerId())
// ->setCustomerEmail($order->getCustomerEmail())
// ->setCustomerGroupId($order->getCustomerGroupId())
// ->setCustomerTaxClassId($order->getCustomerTaxClassId())
// /**
// * Not use note from previos order
// */
// //->setCustomerNote($order->getCustomerNote())
// //->setCustomerNoteNotify($order->getCustomerNoteNotify())
// ->setCustomerIsGuest($order->getCustomerIsGuest())
//
// /**
// * Currency data
// */
// ->setBaseCurrencyCode($order->getBaseCurrencyCode())
// ->setStoreCurrencyCode($order->getStoreCurrencyCode())
// ->setQuoteCurrencyCode($order->getOrderCurrencyCode())
// ->setStoreToBaseRate($order->getStoreToBaseRate())
// ->setStoreToQuoteRate($order->getStoreToOrderRate())
//
// /**
// * Totals data
// */
// ->setGrandTotal($order->getGrandTotal())
// ->setBaseGrandTotal($order->getBaseGrandTotal())
//
// /**
// * Another data
// */
// ->setCouponCode($order->getCouponCode())
// ->setGiftcertCode($order->getGiftcertCode())
// ->setAppliedRuleIds($order->getAppliedRuleIds());
// //->collectTotals();
//
AO::dispatchEvent('sales_convert_order_to_quote', array('order' => $order, 'quote' => $quote));
return $quote;
}
示例13: getRate
public function getRate()
{
if (!$this->getCountryId() || !$this->getCustomerClassId() || !$this->getProductClassId()) {
return 0;
#throw AO::exception('Mage_Tax', AO::helper('tax')->__('Invalid data for tax rate calculation'));
}
$cacheKey = $this->getCustomerClassId() . '|' . $this->getProductClassId() . '|' . $this->getCountryId() . '|' . $this->getRegionId() . '|' . $this->getPostcode();
if (!isset($this->_cache[$cacheKey])) {
$this->unsRateValue();
AO::dispatchEvent('tax_rate_data_fetch', array('request' => $this));
if (!$this->hasRateValue()) {
$this->setRateValue($this->_getResource()->fetchRate($this));
}
$this->_cache[$cacheKey] = $this->getRateValue();
}
return $this->_cache[$cacheKey];
}
示例14: _initCatagory
/**
* Initialize requested category object
*
* @return Mage_Catalog_Model_Category
*/
protected function _initCatagory()
{
AO::dispatchEvent('catalog_controller_category_init_before', array('controller_action' => $this));
$categoryId = (int) $this->getRequest()->getParam('id', false);
if (!$categoryId) {
return false;
}
$category = AO::getModel('catalog/category')->setStoreId(AO::app()->getStore()->getId())->load($categoryId);
if (!AO::helper('catalog/category')->canShow($category)) {
return false;
}
AO::getSingleton('catalog/session')->setLastVisitedCategoryId($category->getId());
AO::register('current_category', $category);
try {
AO::dispatchEvent('catalog_controller_category_init_after', array('category' => $category, 'controller_action' => $this));
} catch (Mage_Core_Exception $e) {
AO::logException($e);
return false;
}
return $category;
}
示例15: removeAction
/**
* Remove item from compare list
*/
public function removeAction()
{
if ($productId = (int) $this->getRequest()->getParam('product')) {
$product = AO::getModel('catalog/product')->setStoreId(AO::app()->getStore()->getId())->load($productId);
if ($product->getId()) {
$item = AO::getModel('catalog/product_compare_item');
if (AO::getSingleton('customer/session')->isLoggedIn()) {
$item->addCustomerData(AO::getSingleton('customer/session')->getCustomer());
} else {
$item->addVisitorId(AO::getSingleton('log/visitor')->getId());
}
$item->loadByProduct($product);
if ($item->getId()) {
$item->delete();
AO::getSingleton('catalog/session')->addSuccess($this->__('Product %s successfully removed from compare list', $product->getName()));
AO::dispatchEvent('catalog_product_compare_remove_product', array('product' => $item));
AO::helper('catalog/product_compare')->calculate();
}
}
}
$this->_redirectReferer();
}