本文整理汇总了PHP中Varien_Event_Observer::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getData方法的具体用法?PHP Varien_Event_Observer::getData怎么用?PHP Varien_Event_Observer::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catalogCategoryChangeProducts
public function catalogCategoryChangeProducts(Varien_Event_Observer $observer)
{
try {
$changedProductsIds = $observer->getData('product_ids');
if (!is_array($changedProductsIds) || count($changedProductsIds) <= 0) {
return;
}
$addedProducts = array();
$deletedProducts = array();
$postedProductsIds = array_keys($observer->getData('category')->getData('posted_products'));
foreach ($changedProductsIds as $productId) {
if (in_array($productId, $postedProductsIds)) {
$addedProducts[] = $productId;
} else {
$deletedProducts[] = $productId;
}
}
if (count($addedProducts) <= 0 && count($deletedProducts) <= 0) {
return;
}
self::synchChangesWithListings($observer->getData('category')->getId(), $addedProducts, $deletedProducts);
} catch (Exception $exception) {
Mage::helper('M2ePro/Exception')->process($exception, true);
return;
}
}
示例2: addOrderItemConditions
public function addOrderItemConditions(Varien_Event_Observer $observer)
{
/** @var Aoe_FraudManager_Helper_Data $helper */
$helper = Mage::helper('Aoe_FraudManager/Data');
/** @var Aoe_FraudManager_Model_Rule_Condition_Interface $parent */
$parent = $observer->getData('parent');
if (!$parent instanceof Aoe_FraudManager_Model_Rule_Condition_Interface) {
return;
}
/** @var Varien_Object $container */
$container = $observer->getData('container');
if (!$container instanceof Varien_Object) {
return;
}
$conditions = $container->getData('conditions');
if (!is_array($conditions)) {
$conditions = [];
}
/** @var Aoe_FraudManager_Model_Rule_Condition_Order_Item_Combine $condition */
$condition = Mage::getModel('Aoe_FraudManager/Rule_Condition_Order_Item_Combine');
$conditions[$condition->getType()] = $helper->__($condition->getName());
/** @var Aoe_FraudManager_Model_Rule_Condition_Order_Item_Attribute $condition */
$condition = Mage::getModel('Aoe_FraudManager/Rule_Condition_Order_Item_Attribute');
$conditionName = $helper->__($condition->getName());
foreach ($condition->getAttributeOptions() as $attribute => $label) {
$conditions[$conditionName][$condition->getType() . '|' . $attribute] = $label;
}
$container->setData('conditions', $conditions);
}
示例3: getParams
/**
* get params of the event
*
* @return array
*/
public function getParams()
{
$params = array();
foreach ($this->_observer->getData() as $name => $param) {
if ($name !== "event") {
$params[$name] = $param;
}
}
return $params;
}
示例4: catalogUpdate
/**
* Daily update catalog to conversionpro server by cron
* This method is called from cron process, cron is workink in UTC time and
*
* @param Varien_Event_Observer $observer
* @return Celebros_Conversionpro_Model_Observer
*/
public function catalogUpdate($observer)
{
//This data is saved to the registry so that it would persist when isStoreExportEnabled()
// is called from within another class (observerLarge).
Mage::helper('conversionpro')->setCronJobCode($observer->getData('job_code'));
$this->export_celebros(false);
return $this;
}
示例5: catalogInventoryStockItemSaveAfter
public function catalogInventoryStockItemSaveAfter(Varien_Event_Observer $observer)
{
try {
// Get product id
$productId = $observer->getData('item')->getData('product_id');
// Get listing where is product
$listingsIds = Mage::getResourceModel('M2ePro/Listings')->getListingsWhereIsProduct($productId);
if (count($listingsIds) > 0) {
// Save global changes
//--------------------
Mage::getModel('M2ePro/ProductsChanges')->updateAttribute($productId, 'product_instance', 'any_old', 'any_new', Ess_M2ePro_Model_ProductsChanges::CREATOR_TYPE_OBSERVER);
//--------------------
// Save changes for qty
//--------------------
$qtyOld = (int) $observer->getData('item')->getOrigData('qty');
$qtyNew = (int) $observer->getData('item')->getData('qty');
$rez = Mage::getModel('M2ePro/ProductsChanges')->updateAttribute($productId, 'qty', $qtyOld, $qtyNew, Ess_M2ePro_Model_ProductsChanges::CREATOR_TYPE_OBSERVER);
if ($rez !== false) {
foreach ($listingsIds as $listingId) {
Mage::getModel('M2ePro/ListingsLogs')->addProductMessage($listingId, $productId, Ess_M2ePro_Model_ListingsLogs::INITIATOR_EXTENSION, NULL, Ess_M2ePro_Model_ListingsLogs::ACTION_CHANGE_PRODUCT_QTY, Mage::getModel('M2ePro/LogsBase')->encodeDescription('From [%from%] to [%to%]', array('!from' => $qtyOld, '!to' => $qtyNew)), Ess_M2ePro_Model_ListingsLogs::TYPE_NOTICE, Ess_M2ePro_Model_ListingsLogs::PRIORITY_LOW);
}
}
//--------------------
// Save changes for stock Availability
//--------------------
$stockAvailabilityOld = (bool) $observer->getData('item')->getOrigData('is_in_stock');
$stockAvailabilityNew = (bool) $observer->getData('item')->getData('is_in_stock');
$rez = Mage::getModel('M2ePro/ProductsChanges')->updateAttribute($productId, 'stock_availability', (int) $stockAvailabilityOld, (int) $stockAvailabilityNew, Ess_M2ePro_Model_ProductsChanges::CREATOR_TYPE_OBSERVER);
if ($rez !== false) {
$stockAvailabilityOld = $stockAvailabilityOld ? 'IN Stock' : 'OUT of Stock';
$stockAvailabilityNew = $stockAvailabilityNew ? 'IN Stock' : 'OUT of Stock';
foreach ($listingsIds as $listingId) {
Mage::getModel('M2ePro/ListingsLogs')->addProductMessage($listingId, $productId, Ess_M2ePro_Model_ListingsLogs::INITIATOR_EXTENSION, NULL, Ess_M2ePro_Model_ListingsLogs::ACTION_CHANGE_PRODUCT_STOCK_AVAILABILITY, Mage::getModel('M2ePro/LogsBase')->encodeDescription('From [%from%] to [%to%]', array('from' => $stockAvailabilityOld, 'to' => $stockAvailabilityNew)), Ess_M2ePro_Model_ListingsLogs::TYPE_NOTICE, Ess_M2ePro_Model_ListingsLogs::PRIORITY_LOW);
}
}
//--------------------
}
} catch (Exception $exception) {
try {
Mage::helper('M2ePro/Exception')->process($exception, true);
} catch (Exception $exceptionTemp) {
}
return;
}
}
示例6: catalogCategoryCollectionLoadAfter
public function catalogCategoryCollectionLoadAfter(Varien_Event_Observer $event)
{
/** @var Mage_Catalog_Model_Resource_Category_Collection $collection */
$collection = $event->getData('category_collection');
foreach ($collection as $category) {
if ($url = $category->getData(VinaiKopp_CategoryLink_Helper_Data::ATTR_CODE_LINK)) {
$category->setData('url', $url);
}
}
}
示例7: catalogCategoryChangeProducts
public function catalogCategoryChangeProducts(Varien_Event_Observer $observer)
{
try {
// Get category data
//---------------------------
$categoryId = $observer->getData('category')->getId();
$storeId = $observer->getData('category')->getData('store_id');
//---------------------------
// Get changes into categories
//---------------------------
$changedProductsIds = $observer->getData('product_ids');
if (count($changedProductsIds) == 0) {
return;
}
$tempArray = $observer->getData('category')->getData('posted_products');
$postedProductsIds = array();
foreach ($tempArray as $key => $value) {
$postedProductsIds[] = $key;
}
$addedProducts = array();
$deletedProducts = array();
foreach ($changedProductsIds as $productId) {
if (in_array($productId, $postedProductsIds)) {
$addedProducts[] = $productId;
} else {
$deletedProducts[] = $productId;
}
}
if (count($addedProducts) == 0 && count($deletedProducts) == 0) {
return;
}
//---------------------------
// Make changes with listings
self::synchChangesWithListings($categoryId, $storeId, $addedProducts, $deletedProducts);
} catch (Exception $exception) {
try {
Mage::helper('M2ePro/Exception')->process($exception, true);
} catch (Exception $exceptionTemp) {
}
return;
}
}
示例8: updateRemainingMessages
/**
* If an Esendex Account is cached, update the remaining messages to reflect what we just sent
*
* @param Varien_Event_Observer $observer
*/
public function updateRemainingMessages(Varien_Event_Observer $observer)
{
$messagesSent = $observer->getData('message_count');
if ($account = Mage::app()->getCache()->load('esendex_account')) {
/** @var Account $account */
$account = unserialize($account);
$account->messagesRemaining($account->messagesRemaining() - $messagesSent);
//re-save account to cache
Mage::app()->getCache()->save(serialize($account), 'esendex_account');
}
}
示例9: controllerPreDispatch
/**
* Forward to xcomDenied action
* if no full Xcom data and user try to open one of xcom page except Xcom_Xfabric and Xcom_Stub
*
* @param Varien_Event_Observer $observer
* @return Xcom_Initializer_Model_Observer
*/
public function controllerPreDispatch($observer)
{
/* @var $controller Mage_Core_Controller_Varien_Action */
$controller = $observer->getData('controller_action');
if ($controller->getRequest()->isDispatched() && !Mage::getSingleton('xcom_initializer/initializer')->isAllowed($controller->getRequest())) {
Mage::getSingleton('adminhtml/session')->setIsUrlNotice($controller->getFlag('', Mage_Adminhtml_Controller_Action::FLAG_IS_URLS_CHECKED));
$request = $controller->getRequest();
$request->initForward()->setControllerName('initializer')->setModuleName('admin')->setActionName('xcomDenied')->setDispatched(false);
}
return $this;
}
示例10: onAdminhtmlBlockHtmlBefore
/**
* Extend UI blocks.
* @param Varien_Event_Observer $observer
*/
public function onAdminhtmlBlockHtmlBefore(Varien_Event_Observer $observer)
{
if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
$block = $observer->getData('block');
if ($block instanceof Mage_Adminhtml_Block_Customer_Grid) {
$this->doCustomerGridActionAdd($block);
} elseif ($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
$this->doOrderGridColumnAdd($block);
}
}
}
示例11: catalogCategoryChangeProducts
public function catalogCategoryChangeProducts(Varien_Event_Observer $observer)
{
try {
/** @var Mage_Catalog_Model_Category $category */
$category = $observer->getData('category');
$categoryId = (int) $category->getId();
$websiteId = (int) $category->getStore()->getWebsiteId();
$changedProductsIds = $observer->getData('product_ids');
$postedProductsIds = array_keys($observer->getData('category')->getData('posted_products'));
if (!is_array($changedProductsIds) || count($changedProductsIds) <= 0) {
return;
}
$websitesProductsIds = array(0 => $changedProductsIds);
if ($websiteId == 0) {
foreach ($changedProductsIds as $productId) {
$productModel = Mage::getModel('M2ePro/Magento_Product')->setProductId($productId);
foreach ($productModel->getWebsiteIds() as $websiteId) {
$websitesProductsIds[$websiteId][] = $productId;
}
}
} else {
$websitesProductsIds[$websiteId] = $changedProductsIds;
}
/** @var Ess_M2ePro_Model_Observer_Ebay_Category $ebayCategoryObserver */
$ebayCategoryObserver = Mage::getModel('M2ePro/Observer_Ebay_Category');
foreach ($websitesProductsIds as $websiteId => $productIds) {
foreach ($productIds as $productId) {
if (in_array($productId, $postedProductsIds)) {
$this->synchProductWithAddedCategoryId($productId, $categoryId, $websiteId);
$ebayCategoryObserver->synchProductWithAddedCategoryId($productId, $categoryId, $websiteId);
} else {
$this->synchProductWithDeletedCategoryId($productId, $categoryId, $websiteId);
$ebayCategoryObserver->synchProductWithDeletedCategoryId($productId, $categoryId, $websiteId);
}
}
}
} catch (Exception $exception) {
Mage::helper('M2ePro/Module_Exception')->process($exception);
return;
}
}
示例12: pageBlockHtmlTopmenuGethtmlBefore
/**
* Hide the catalog navigation to logged out visitors if the feature is configured.
*
* @param Varien_Event_Observer $observer
*/
public function pageBlockHtmlTopmenuGethtmlBefore(Varien_Event_Observer $observer)
{
if (Mage::helper('logincatalog')->shouldHideCategoryNavigation()) {
/** @var $menu Varien_Data_Tree_Node */
$menu = $observer->getData('menu');
foreach ($menu->getChildren() as $key => $node) {
if (strpos($key, 'category-') === 0) {
$menu->removeChild($node);
}
}
}
}
示例13: validateQuoteAddress
/**
* @see Mage_Customer_Model_Address_Abstract::validate
*
* @param Varien_Event_Observer $observer
*/
public function validateQuoteAddress(Varien_Event_Observer $observer)
{
/** @var Mage_Sales_Model_Quote_Address $address */
$address = $observer->getData('address');
// If the address property of the observer data is not the correct type, exit early
if (!$address instanceof Mage_Sales_Model_Quote_Address) {
return;
}
/** @var Aoe_AvaTax_Helper_AddressValidator $validator */
$validator = Mage::helper('Aoe_AvaTax/AddressValidator');
$validator->validate($address);
}
示例14: sales_order_afterPlace
/**
* Observer used to record a rule usage and a coupon usage
*
* NB: This replaces the parent method so that event zero value discounts are recorded properly and to remove race conditions
*
* @param Varien_Event_Observer $observer
*
* @return void
*/
public function sales_order_afterPlace(Varien_Event_Observer $observer)
{
/** @var Mage_Sales_Model_Order $order */
$order = $observer->getData('order');
if (!$order instanceof Mage_Sales_Model_Order) {
return;
}
// Get the used rule IDs
$ruleIds = array_unique(array_filter(array_map('intval', explode(',', $order->getAppliedRuleIds()))));
$ruleCustomer = null;
$customerId = $order->getCustomerId();
// use each rule (and apply to customer, if applicable)
foreach ($ruleIds as $ruleId) {
/** @var Mage_SalesRule_Model_Rule $rule */
$rule = Mage::getModel('salesrule/rule');
$rule->load($ruleId);
if (!$rule->getId()) {
continue;
}
// Update the rule usage counter - the DB expression is used to prevent race conditions
$rule->setDataUsingMethod('times_used', new Zend_Db_Expr('times_used+1'));
$rule->save();
if ($customerId) {
// If we add a unique index of rule and customer we can use \Varien_Db_Adapter_Interface::insertOnDuplicate to prevent race conditions
/** @var Mage_SalesRule_Model_Rule_Customer $ruleCustomer */
$ruleCustomer = Mage::getModel('salesrule/rule_customer');
$ruleCustomer->loadByCustomerRule($customerId, $ruleId);
if ($ruleCustomer->getId()) {
// Update the usage counter - the DB expression is used to prevent race conditions
$ruleCustomer->setDataUsingMethod('times_used', new Zend_Db_Expr('times_used+1'));
} else {
$ruleCustomer->setCustomerId($customerId)->setRuleId($ruleId)->setTimesUsed(1);
}
$ruleCustomer->save();
}
}
// Trim the coupon code to match all the other coupon code processing
$couponCode = trim($order->getCouponCode());
if (!empty($couponCode)) {
/** @var Mage_SalesRule_Model_Coupon $coupon */
$coupon = Mage::getModel('salesrule/coupon');
$coupon->load($couponCode, 'code');
if ($coupon->getId()) {
$coupon->setDataUsingMethod('times_used', new Zend_Db_Expr('times_used+1'));
$coupon->save();
if ($customerId) {
/** @var Aoe_SalesRule_Model_Resource_Coupon_Usage $couponUsage */
$couponUsage = Mage::getResourceModel('salesrule/coupon_usage');
$couponUsage->updateCustomerCouponTimesUsed($customerId, $coupon->getId());
}
}
}
}
示例15: updateProductRatingSummary
public function updateProductRatingSummary(Varien_Event_Observer $observer)
{
if (Mage::helper('avisverifies/Data')->isActive()) {
$globalVar = Mage::registry('netreview_isProductlist');
if (empty($globalVar)) {
Mage::register('netreview_isProductlist', true);
}
$_productCollection = $observer->getData('collection');
foreach ($_productCollection as $_product) {
$_product->setData('rating_summary', true);
}
}
}