本文整理汇总了PHP中Varien_Event_Observer::getAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getAction方法的具体用法?PHP Varien_Event_Observer::getAction怎么用?PHP Varien_Event_Observer::getAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getAction方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log
/**
* Log the data for the given observer model.
*
* @param Varien_Event_Observer $observer Observer Instance
*/
public function log(Varien_Event_Observer $observer)
{
/* @var $history FireGento_AdminMonitoring_Model_History */
$history = Mage::getModel('firegento_adminmonitoring/history');
$history->setData(array('object_id' => $observer->getObjectId(), 'object_type' => $observer->getObjectType(), 'content' => $observer->getContent(), 'content_diff' => $observer->getContentDiff(), 'user_agent' => $this->getUserAgent(), 'ip' => $this->getRemoteAddr(), 'user_id' => $this->getUserId(), 'user_name' => $this->getUserName(), 'action' => $observer->getAction(), 'created_at' => now()));
$history->save();
}
示例2: preDispatchCatalogProductView
/**
* Check is load only options on catalog_product_view page
*
* @param Varien_Event_Observer $event
* @return void
*/
public function preDispatchCatalogProductView(Varien_Event_Observer $event)
{
/* @var $action Mage_Core_Controller_Varien_Action */
$action = $event->getAction();
if ($action->getFullActionName() != 'catalog_product_view') {
return;
}
/* @var $request Mage_Core_Controller_Request_Http */
$request = $action->getRequest();
if (!($ajaxRequest = $action->getRequest()->getHeader('X-Requested-With')) || !$request->getParams('ajaxquickcartoption')) {
return;
}
if (!($productId = intval($request->getParam('id')))) {
return;
}
/* @var $product Mage_Catalog_Model_Product */
$product = Mage::getModel('catalog/product')->load($productId);
if ($product->getId() != $productId) {
return;
}
$productType = $product->getTypeId();
/* @var $update Mage_Core_Model_Layout_Update */
$update = $action->getLayout()->getUpdate();
/*$update->addUpdate('<reference name="product.info">
<action method="setTemplate"><template>ajaxquickcart/quickcart/product.phtml</template></action>
</reference>');*/
$update->addHandle('ajaxquickcart_product_view');
$update->addHandle('PRODUCT_TYPE_ajaxquickcart_' . $productType);
//todo: add addtocart ajax on layer
}
示例3: controller_action_layout_load_before
/**
* Performs order_creage_loadBlock response update
* adds totals block to each response
* This function is depricated, the totals block update is implemented
* in phoenix/cashondelivery/sales.js (SalesOrder class extension)
*
* @param Varien_Event_Observer $observer
*/
public function controller_action_layout_load_before(Varien_Event_Observer $observer)
{
$action = $observer->getAction();
if ($action->getFullActionName() != 'adminhtml_sales_order_create_loadBlock' || !$action->getRequest()->getParam('json')) {
return;
}
$layout = $observer->getLayout();
$layout->getUpdate()->addHandle('adminhtml_sales_order_create_load_block_totals');
}
示例4: execute
/**
* Add error message if tax estimation has problems when user estimates post
*
* @param Varien_Event_Observer $observer
* @return $this
*/
public function execute(Varien_Event_Observer $observer)
{
$action = $observer->getAction();
if ($action instanceof Mage_Checkout_CartController && $action->getFullActionName() == 'checkout_cart_index') {
/* @var Mage_Sales_Model_Quote $quote */
$quote = Mage::getSingleton('checkout/session')->getQuote();
$this->_addErrorMessage($quote);
}
return $this;
}
示例5: addLayoutHandleObserver
public function addLayoutHandleObserver(Varien_Event_Observer $observer)
{
$landingpage = Mage::registry('current_landingpage');
if (is_null($landingpage)) {
return $this;
}
// no landingpage
$landingpage_id = $landingpage->getId();
$layout = $observer->getAction()->getLayout();
$layout->getUpdate()->addHandle('layeredlanding_page');
$layout->getUpdate()->addHandle('layeredlanding_' . $landingpage_id);
$layout->generateXml();
return $this;
}
示例6: addAdminhtmlSalesOrderCreateHandles
/**
* @event controller_action_layout_load_before
* @param Varien_Event_Observer $observer
*/
public function addAdminhtmlSalesOrderCreateHandles(Varien_Event_Observer $observer)
{
/** @noinspection PhpUndefinedMethodInspection */
if (!$observer->getAction() instanceof Mage_Adminhtml_Sales_Order_CreateController) {
return;
}
$subscriptionId = Mage::app()->getRequest()->getParam('subscription');
$subscription = Mage::getModel('adyen_subscription/subscription')->load($subscriptionId);
if (!$subscription->getId()) {
return;
}
Mage::register('current_subscription', $subscription);
Mage::app()->getLayout()->getUpdate()->addHandle('adyen_subscription_active_quote_edit');
}
示例7: emptyCart
/**
* Empty shopping cart
*
* @param Varien_Event_Observer $observer
* @return H5mag_ShopApi_Model_Order_Observer
*/
public function emptyCart($observer)
{
$controller = $observer->getAction();
if ($controller instanceof Mage_Checkout_OnepageController) {
$action = $controller->getFullActionName();
if ($action == 'checkout_onepage_success') {
$layout = $observer->getLayout();
$layout->getUpdate()->addUpdate('
<reference name="content">
<block name="shopapi.cart" type="core/template" template="h5mag/shopapi/emptycart.phtml">
</block>
</reference>
');
}
}
return $this;
}
示例8: execute
/**
* Recalculates taxes during order creation in admin panel.
* quote item is null during first collect totals,
* that is why rate request does not send to avalara.
*
* @param Varien_Event_Observer $observer
*
* @return $this
*/
public function execute(Varien_Event_Observer $observer)
{
$action = $observer->getAction();
if ($action instanceof Mage_Adminhtml_Sales_Order_CreateController && $action->getRequest()->getActionName() == 'loadBlock') {
$requestBlocks = $action->getRequest()->getParam('block');
if (isset($requestBlocks) && strstr($requestBlocks, 'totals')) {
/* @var Mage_Adminhtml_Model_Session_Quote $adminQuote */
$adminQuote = Mage::getSingleton('adminhtml/session_quote');
/* @var Mage_Sales_Model_Quote $quote */
$quote = isset($adminQuote) ? $adminQuote->getQuote() : null;
if (isset($quote)) {
$quote->setTotalsCollectedFlag(false);
$quote->collectTotals();
$quote->save();
}
}
}
return $this;
}
示例9: setCurrentCategory
public function setCurrentCategory(Varien_Event_Observer $observer)
{
$action = $observer->getAction();
if ($action->getFullActionName() != 'catalog_product_view') {
return;
}
if (Mage::app()->getRequest()->getParam('c', 0)) {
return;
}
$currentProduct = Mage::registry('current_product');
if (!$currentProduct) {
return;
}
$catIds = $currentProduct->getCategoryIds();
if (!is_array($catIds) || !count($catIds)) {
return;
}
$category = $this->_getHighestLevelCategory($catIds);
if ($category && $category->getId()) {
Mage::unregister('current_category');
Mage::register('current_category', $category);
}
}
示例10: addLayoutHandle
/**
* Detect which checkout is in use and add a new layout handle
*
* @param Varien_Event_Observer $observer
*
* @return $this
*/
public function addLayoutHandle(Varien_Event_Observer $observer)
{
/* @var $action Mage_Core_Controller_Varien_Action */
$action = $observer->getAction();
/* @var $layout Mage_Core_Model_Layout */
$layout = $observer->getLayout();
// We only want to run this action on the checkout
if ($action->getFullActionName() == 'checkout_onepage_index') {
// Attempt to detect Amasty_Scheckout
if (Mage::helper('core')->isModuleEnabled('Amasty_Scheckout')) {
$layout->getUpdate()->addHandle('amasty_onestep_checkout');
}
// Attempt to detect Unicode OP Checkout
if (Mage::helper('core')->isModuleEnabled('Uni_Opcheckout') && Mage::helper('opcheckout')->isActive()) {
$layout->getUpdate()->addHandle('unicode_onestep_checkout');
}
// Detect the Oye one step checkout
if (Mage::helper('core')->isModuleEnabled('Oye_Checkout') && Mage::helper('oyecheckout')->isOneStepLayout()) {
$layout->getUpdate()->addHandle('oye_onestep_checkout');
}
}
// As some 3rd party checkouts use the same handles, and URL we have to dynamically add new handles
if ($action->getFullActionName() == 'onestepcheckout_index_index') {
// Attempt to detect Magestore_Onestepcheckout
if (Mage::helper('core')->isModuleEnabled('Magestore_Onestepcheckout')) {
if (Mage::helper('onestepcheckout')->enabledOnestepcheckout()) {
$layout->getUpdate()->addHandle('magestore_onestepcheckout_index');
}
}
// Attempt to detect Idev_OneStepCheckout
if (Mage::helper('core')->isModuleEnabled('Idev_OneStepCheckout')) {
$layout->getUpdate()->addHandle('idev_onestepcheckout_index');
}
}
return $this;
}
示例11: intModeCheck
/**
* Define integration mode and add handle
*
* @param Varien_Event_Observer $observer
*/
public function intModeCheck(Varien_Event_Observer $observer)
{
if (Mage::helper('conversionpro')->isConversionproEnabled()) {
$actions = array_keys((array) Mage::getConfig()->getNode('conversionpro/search_actions'));
$nav2search_actions = array_keys((array) Mage::getConfig()->getNode('conversionpro/nav2search_actions'));
$current_action = (string) $observer->getAction()->getFullActionName();
$update = $observer->getEvent()->getLayout()->getUpdate();
if (count($actions) && in_array($current_action, $actions) || count($nav2search_actions) && in_array($current_action, $nav2search_actions) && Mage::getStoreConfig('conversionpro/nav_to_search_settings/nav_to_search')) {
if (Mage::getStoreConfig('conversionpro/nav_to_search_settings/nav_to_search') && Mage::getStoreConfig('conversionpro/nav_to_search_settings/nav_to_search_enable_blacklist')) {
$current_category = Mage::registry('current_category');
if ($current_category) {
$blacklist = Mage::getStoreConfig('conversionpro/nav_to_search_settings/nav_to_search_blacklist');
if (in_array($current_category->getEntityId(), explode(',', $blacklist))) {
return;
}
}
}
$this->addSearchHandle($update);
if (Mage::helper('conversionpro')->isHideContent()) {
$this->hideContent($update);
}
}
}
/*Zend_Debug::dump(Mage::app()->getLayout()->getUpdate()->getHandles()); exit;*/
}
示例12: clearRetriesForOrder
/**
* Clear all submission retries for an order that have the same action.
* This event observer is only called after a successful submission.
*
* @param Varien_Event_Observer $observer
*/
public function clearRetriesForOrder(Varien_Event_Observer $observer)
{
$order = $observer->getOrder();
// Sanity check
if (!$order || !$order->getId()) {
return;
}
$retries = Mage::getModel('full/retry')->getCollection()->addfieldtofilter('order_id', $order->getId())->addFieldToFilter('action', $observer->getAction());
foreach ($retries as $retry) {
$retry->delete();
}
}
示例13: catalogCategoryEditAction
/**
* Lock category attributes
* @param Varien_Event_Observer $observer
*/
public function catalogCategoryEditAction(Varien_Event_Observer $observer)
{
/** @var Mage_Core_Controller_Request_Http $request */
$request = $observer->getAction()->getRequest();
if ($request->getControllerName() !== 'catalog_category' || $request->getModuleName() !== 'admin') {
return;
}
$category = Mage::registry('current_category');
$this->_lockAttributes($category);
}