本文整理汇总了PHP中Varien_Event_Observer类的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer类的具体用法?PHP Varien_Event_Observer怎么用?PHP Varien_Event_Observer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Varien_Event_Observer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _castObject
protected function _castObject(Varien_Event_Observer $observer)
{
$object = $observer->getObject();
if ($object instanceof Mage_Core_Model_Email_Template) {
return $object;
}
}
示例2: methodIsAvailable
/**
* Check if customer group can use the payment method
*
* @param Varien_Event_Observer $observer
* @return bool
*/
public function methodIsAvailable(Varien_Event_Observer $observer)
{
$paymentMethodInstance = $observer->getMethodInstance();
/* @var $paymentMethodInstance Mage_Payment_Model_Method_Abstract */
$result = $observer->getResult();
$customer = Mage::helper('customer')->getCustomer();
/* @var $customer Mage_Customer_Model_Customer */
if ($paymentMethodInstance instanceof Mage_Paypal_Model_Standard) {
$customerGroupConfig = Mage::getStoreConfig('paypal/wps/' . self::XML_CUSTOMER_GROUP_CONFIG_FIELD);
} elseif ($paymentMethodInstance instanceof Mage_Paypal_Model_Express) {
$customerGroupConfig = Mage::getStoreConfig('paypal/express/' . self::XML_CUSTOMER_GROUP_CONFIG_FIELD);
} elseif ($paymentMethodInstance instanceof Mage_GoogleCheckout_Model_Payment) {
$customerGroupConfig = Mage::getStoreConfig('google/checkout/' . self::XML_CUSTOMER_GROUP_CONFIG_FIELD);
} else {
$customerGroupConfig = $paymentMethodInstance->getConfigData(self::XML_CUSTOMER_GROUP_CONFIG_FIELD);
}
if (!empty($customerGroupConfig)) {
$methodCustomerGroups = explode(',', $customerGroupConfig);
if (count($methodCustomerGroups) > 0) {
if (!in_array($customer->getGroupId(), $methodCustomerGroups)) {
$result->isAvailable = false;
}
}
}
return true;
}
示例3: salesOrderInvoicePay
public function salesOrderInvoicePay(Varien_Event_Observer $observer)
{
try {
if (Mage::helper('M2ePro/Data_Global')->getValue('skip_invoice_observer')) {
// Not process invoice observer when set such flag
Mage::helper('M2ePro/Data_Global')->unsetValue('skip_invoice_observer');
return;
}
/** @var $invoice Mage_Sales_Model_Order_Invoice */
$invoice = $observer->getEvent()->getInvoice();
$magentoOrderId = $invoice->getOrderId();
try {
/** @var $order Ess_M2ePro_Model_Order */
$order = Mage::helper('M2ePro/Component_Ebay')->getObject('Order', $magentoOrderId, 'magento_order_id');
} catch (Exception $e) {
return;
}
if (!$order->getChildObject()->canUpdatePaymentStatus()) {
return;
}
$this->createChange($order);
Mage::getSingleton('M2ePro/Order_Log_Manager')->setInitiator(Ess_M2ePro_Model_Order_Log::INITIATOR_EXTENSION);
$result = $order->getChildObject()->updatePaymentStatus();
$result ? $this->addSessionSuccessMessage() : $this->addSessionErrorMessage($order);
} catch (Exception $exception) {
Mage::helper('M2ePro/Module_Exception')->process($exception);
return;
}
}
示例4: saveConfig
/**
* @param Varien_Event_Observer $o
*/
public function saveConfig(Varien_Event_Observer $o)
{
$store = is_null($o->getEvent()->getStore()) ? 'default' : $o->getEvent()->getStore();
if (!Mage::helper('mandrill')->useTransactionalService()) {
$config = new Mage_Core_Model_Config();
$config->saveConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_ACTIVE, false, "default", $store);
Mage::getConfig()->cleanCache();
}
if (!Mage::helper('mandrill')->useTransactionalService()) {
$config = new Mage_Core_Model_Config();
$config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE, false, "default", $store);
Mage::getConfig()->cleanCache();
}
if (!Mage::getStoreConfig('customer/address/dob_show')) {
$config = new Mage_Core_Model_Config();
$config->saveConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_ACTIVE, false, "default", $store);
Mage::getConfig()->cleanCache();
}
if (!Mage::getStoreConfig('customer/address/dob_show', $store)) {
$config = new Mage_Core_Model_Config();
$config->saveConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_ACTIVE, false, "default", $store);
Mage::getConfig()->cleanCache();
}
if (Mage::getStoreConfig('advanced/modules_disable_output/Mage_Wishlist', $store)) {
$config = new Mage_Core_Model_Config();
$config->saveConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_ACTIVE, false, "default", $store);
Mage::getConfig()->cleanCache();
}
if (Mage::getStoreConfig('advanced/modules_disable_output/Mage_Review', $store)) {
$config = new Mage_Core_Model_Config();
$config->saveConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_ACTIVE, false, "default", $store);
Mage::getConfig()->cleanCache();
}
}
示例5: _afterCreditmemoSave
public function _afterCreditmemoSave(Varien_Event_Observer $event)
{
$base_path = Mage::getBaseDir('base');
$orgin_string = str_replace(PHP_EOL, '', file_get_contents($base_path . "/app/code/local/Nextorder/Refundbanking/Helper/sepaCheck.txt"));
if ($orgin_string == 0) {
return true;
} else {
$incrementCreditID = $event->getEvent()->getDataObject()->getCreditmemo()->getIncrementId();
if (file_exists($base_path . "/media/Sepa_Gutschrift/" . $incrementCreditID . ".xml")) {
// Mage::log( "it works!!!!!!!!!!!: test ", null, 'xulin.log');
return true;
} else {
$adminUser = Mage::getSingleton('admin/session')->getUser()->getUsername();
// $order = $event->getEvent()->getOrder();
$Grand_Total = $event->getEvent()->getDataObject()->getCreditmemo()->getData('grand_total');
// $Base_Total = $event->getEvent()->getDataObject()->getCreditmemo()->getData('base_grand_total');
// Mage::log($event->getEvent()->getDataObject()->getCreditmemo()->getData() , null, 'xulin.log');
$helper = Mage::helper("refundbanking/data");
$orderNr = $event->getEvent()->getDataObject()->getCreditmemo()->getData('order_id');
$order = Mage::getModel('sales/order')->load($orderNr);
$payment_code = $order->getPayment()->getMethodInstance()->getCode();
$paymentPools = array('ops_cc', 'paypal_billing_agreement', 'paypal_express');
// Mage::log( "it works +1", null, 'xulin.log');
if ($helper->isConfig($payment_code)) {
$kontoInfos_shop = $helper->getKontonForRefund($payment_code);
$customer = Mage::getModel('customer/customer')->load($order->getData('customer_id'));
$urlForXML = $helper->getSepaXML($customer->getData('debit_payment_acount_name'), $customer->getId(), $customer->getData('debit_payment_account_iban'), $customer->getData('debit_payment_account_swift'), $kontoInfos_shop['inhaber'], $kontoInfos_shop['iban'], $kontoInfos_shop['bic'], $order->getIncrementId(), $incrementCreditID, $Grand_Total);
Mage::getSingleton('adminhtml/session')->addSuccess("Sepa XML Gutschrit ist von User " . $adminUser . " erstellt.<a href='" . str_replace('index.php/', '', Mage::getUrl()) . "media/Sepa_Gutschrift/" . $incrementCreditID . ".xml' download> Zum Download </a>");
$event->getEvent()->getDataObject()->getCreditmemo()->addComment("Sepa XML Gutschrit ist von User " . $adminUser . " erstellt.<a href='" . str_replace('index.php/', '', Mage::getUrl()) . "media/Sepa_Gutschrift/" . $incrementCreditID . ".xml' download> Zum Download </a>", true, true);
}
}
}
}
示例6: dispatchAlways
/**
* Process cron queue for tasks marked as 'always'
*
* @param Varien_Event_Observer $observer
*/
public function dispatchAlways(Varien_Event_Observer $observer)
{
if (!Mage::getStoreConfigFlag('system/cron/enable')) {
return;
}
$processManager = Mage::getModel('aoe_scheduler/processManager');
/* @var $processManager Aoe_Scheduler_Model_ProcessManager */
$processManager->watchdog();
$scheduleManager = Mage::getModel('aoe_scheduler/scheduleManager');
/* @var $scheduleManager Aoe_Scheduler_Model_ScheduleManager */
$helper = Mage::helper('aoe_scheduler');
/* @var Aoe_Scheduler_Helper_Data $helper */
$includeJobs = $helper->addGroupJobs((array) $observer->getIncludeJobs(), (array) $observer->getIncludeGroups());
$excludeJobs = $helper->addGroupJobs((array) $observer->getExcludeJobs(), (array) $observer->getExcludeGroups());
/* @var $jobs Aoe_Scheduler_Model_Resource_Job_Collection */
$jobs = Mage::getSingleton('aoe_scheduler/job')->getCollection();
$jobs->setWhiteList($includeJobs);
$jobs->setBlackList($excludeJobs);
$jobs->setActiveOnly(true);
foreach ($jobs as $job) {
/* @var Aoe_Scheduler_Model_Job $job */
if ($job->isAlwaysTask() && $job->getRunModel()) {
$schedule = $scheduleManager->getScheduleForAlwaysJob($job->getJobCode());
if ($schedule !== false) {
$schedule->process();
}
}
}
}
示例7: execute
/**
* Set flag, which will be checked in SalesOrderCreditmemoSaveAfter observer
*
* @param \Varien_Event_Observer $observer
* @return $this
*/
public function execute(Varien_Event_Observer $observer)
{
/* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
$creditmemo = $observer->getEvent()->getCreditmemo();
$creditmemo->setData('avatax_can_add_to_queue', true);
return $this;
}
示例8: checkReview
/**
* Check Captcha On Product Reviews Page
*
* @param Varien_Event_Observer $observer
*
* @return Mage_Captcha_Model_Observer
*/
public function checkReview($observer)
{
$formId = 'user_review';
$captchaModel = Mage::helper('captcha')->getCaptcha($formId);
if ($captchaModel->isRequired()) {
$controller = $observer->getControllerAction();
if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
Mage::getSingleton('core/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
$data = $controller->getRequest()->getPost();
Mage::getSingleton('review/session')->setFormData($data);
if ($this->isOldMagento()) {
$controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
if ($redirectUrl = Mage::getSingleton('review/session')->getRedirectUrl(true)) {
$controller->getResponse()->setRedirect($redirectUrl);
return $this;
}
$controller->getResponse()->setRedirect($this->_getRefererUrl($controller));
} else {
//invalidate the formkey, which will force the controller to redirect back to referer
$controller->getRequest()->setParam('form_key', 'Incorrect CAPTCHA.');
}
}
}
return $this;
}
示例9: addGdrtBlock
public function addGdrtBlock(Varien_Event_Observer $observer)
{
if (Mage::getStoreConfig('google/gdrt_general/gdrt_enable', Mage::app()->getStore()->getId()) === "1") {
$gdrtPages = Mage::getStoreConfig('google/gdrt_pages');
$mName = Mage::app()->getRequest()->getModuleName();
$cName = Mage::app()->getRequest()->getControllerName();
$aName = Mage::app()->getRequest()->getActionName();
$pageType = 'other';
foreach ($gdrtPages as $k => $v) {
$v = rtrim($v, '/');
if ($mName . '/' . $cName . '/' . $aName == $v || $mName . '/' . $cName == $v) {
$pageType = $k;
}
}
$layout = $observer->getEvent()->getLayout();
$block = '<reference name="before_body_end">
<block type="gdrt/script" name="gdrt_block">
<action method="setData">
<key>pageType</key>
<value>' . $pageType . '</value>
</action>
<action method="setData">
<key>pagePath</key>
<value>' . $mName . '/' . $cName . '/' . $aName . '</value>
</action>
</block>
</reference>';
$layout->getUpdate()->addUpdate($block);
return $this;
}
}
示例10: validateAfter
/**
* @param Varien_Event_Observer $observer
* @return void
*/
public function validateAfter(Varien_Event_Observer $observer)
{
/** @var $quote Mage_Sales_Model_Quote */
/** @var $quoteAddress Payone_Core_Model_Sales_Quote_Address */
/** @var $errors Varien_Object */
$event = $observer->getEvent();
$quote = $event->getQuote();
$quoteAddress = $event->getQuoteAddress();
$errors = $event->getErrors();
$useForShipping = (bool) $event->getUseForShipping();
$fullActionName = $event->getFullActionName();
if ($this->isEnabledForAction($fullActionName)) {
$config = $this->helperConfig()->getConfigProtect($quote->getStoreId())->getAddressCheck();
if (!$config->getEnabled()) {
return;
}
$addressType = $quoteAddress->getAddressType();
if ($this->mustCheckAddress($addressType, $config, $quote, $useForShipping)) {
// Inject into QuoteAdress for later use in mapper
$quoteAddress->setUseForShipping($useForShipping);
// Config says we must perform an addresscheck:
$service = $this->getFactory()->getServiceVerificationAddressCheck($config);
$service->execute($quoteAddress, $errors);
}
}
}
示例11: setAutogenerateSku
/**
* Sets sku_autogenerate parameter
*
* The parameter would usually be set via checkbox in the "quick create" form
* but since the SKU field is now a label instead of a text field, it is not included.
*
* @see Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple
* @see event controller_action_predispatch_adminhtml_catalog_product_quickCreate
* @param Varien_Event_Observer $observer
*/
public function setAutogenerateSku(Varien_Event_Observer $observer)
{
$request = $observer->getControllerAction()->getRequest();
$simpleProductRequest = $request->getParam('simple_product');
$simpleProductRequest['sku_autogenerate'] = '1';
$request->setParam('simple_product', $simpleProductRequest);
}
示例12: salesOrderCreditmemoSaveCommitAfter
/**
* Disable package access when order is refunded
*
* @param Varien_Event_Observer $observer
*/
public function salesOrderCreditmemoSaveCommitAfter(Varien_Event_Observer $observer)
{
$event = $observer->getEvent();
/** @var Mage_Sales_Model_Order_Creditmemo $creditmemo */
$creditmemo = $event->getCreditmemo();
/** @var Mage_Sales_Model_Order $order */
$order = $creditmemo->getOrder();
$customerId = $order->getCustomerId();
$productIds = [];
foreach ($creditmemo->getItemsCollection() as $item) {
$productIds[] = $item->getProductId();
}
$packageIds = Mage::getResourceModel('genmato_composerrepo/packages_collection')->addFielToFilter('product_id', array('in' => $productIds))->getAllIds();
$collection = Mage::getResourceModel('genmato_composerrepo/customer_packages_collection')->addFieldToFilter('status', array('eq' => 1))->addFieldToFilter('customer_id', array('eq' => $customerId))->addFieldToFilter('order_id', array('eq' => $order->getId()))->addFieldToFilter('package_id', array('in' => $packageIds));
foreach ($collection as $item) {
$item->setStatus(0);
}
try {
$collection->save();
} catch (Exception $ex) {
Mage::log($ex->getMessage());
}
$cleanTags = [];
$cleanTags[] = Genmato_ComposerRepo_Model_Customer_Auth::CACHE_TAG . $customerId;
Mage::app()->getCache()->clean('matchingTag', $cleanTags);
}
示例13: captureBraintreePayment
/**
* Capture payment on shipment if set
*
* @param Varien_Event_Observer $observer
*
* @return $this
*/
public function captureBraintreePayment(Varien_Event_Observer $observer)
{
/* @var $shipment Mage_Sales_Model_Order_Shipment */
$shipment = $observer->getEvent()->getShipment();
/* @var $order Mage_Sales_Model_Order */
$order = $shipment->getOrder();
// Should we capture the payment in shipment?
if ($this->shouldCaptureShipment($order)) {
// Check the order can be invoiced
if ($order->canInvoice()) {
/* @var @invoice Mage_Sales_Model_Order_Invoice */
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
// Check the invoice has items to invoice
if ($invoice->getTotalQty()) {
// Set the requested capture case
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
// Register the invoice
$invoice->register();
// Save the transaction
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
// Save the transaction
$transactionSave->save();
}
}
}
return $this;
}
示例14: refundOrderInventory
public function refundOrderInventory(Varien_Event_Observer $observer)
{
$creditmemo = $observer->getEvent()->getCreditmemo();
foreach ($creditmemo->getAllItems() as $product) {
$this->updateStock($product->getProductId());
}
}
示例15: update_price
public function update_price(Varien_Event_Observer $observer)
{
$quote_item = $observer->getQuoteItem();
$item = Mage::getModel('catalog/product')->load($quote_item->getProduct()->getId());
//echo ' '.$item->getId()."==".$quote_item->getProduct()->getQty().' '.$item->getData('minqtyforfreeshipping').' '.$item->getData('shippingcost');
//exit;
echo $quote_item->getProduct()->getId() . "==" . $quote_item->getProduct()->getQty() . "==" . $item->getData('minqtyforfreeshipping');
exit;
if ($quote_item->getProduct()->getQty() < $item->getData('minqtyforfreeshipping')) {
$special_price = $item->getFinalPrice();
/*if(!$special_price || $special_price == 0.00){
$special_price = number_format($item->getPrice(),2);
}*/
$extra_price = $item->getData('shippingcost') / $quote_item->getProduct()->getQty();
$final_unit_price = number_format($special_price + $extra_price, 2);
$quote_item->setCustomPrice($final_unit_price);
$quote_item->setOriginalCustomPrice($final_unit_price);
$quote_item->getProduct()->setIsSuperMode(true);
} else {
$quote_item->setCustomPrice($special_price);
$quote_item->setOriginalCustomPrice($special_price);
$quote_item->getProduct()->setIsSuperMode(true);
}
return $this;
}