本文整理汇总了PHP中Varien_Event_Observer::getObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getObject方法的具体用法?PHP Varien_Event_Observer::getObject怎么用?PHP Varien_Event_Observer::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modelSaveAfter
public function modelSaveAfter(Varien_Event_Observer $observer)
{
// only log if the model is on the whitelist
if (Mage::getStoreConfig(self::LOG_ACTION_WHITELIST_PREFIX . get_class($observer->getObject())) !== null) {
$customerSession = Mage::getSingleton('customer/session');
$action = Mage::getModel('hackathon_frontendmonitoring/user_action');
$action->setSessionId($customerSession->getSessionId());
$action->setCustomerId($customerSession->getCustomerId());
$action->setModel(get_class($observer->getObject()));
$action->setAction('save_after');
$action->setTimestamp(Mage::helper('hackathon_frontendmonitoring')->getNow());
$action->save();
}
}
示例2: prepareLayoutHandlesAndBlocks
public function prepareLayoutHandlesAndBlocks(Varien_Event_Observer $observer)
{
$object = $observer->getObject();
$handles = $object->getHandles();
$blockNames = $object->getBlockNames();
$request = $observer->getObserver()->getControllerAction()->getRequest();
$suggestpageHandles = array('suggestpage_index_index', 'tm_ajaxpro_checkout_cart_add_suggestpage');
if (!array_intersect($suggestpageHandles, $handles)) {
return;
}
if ('delete' == $request->getActionName()) {
$handles = $this->_replaceArrayValues($handles, array('tm_ajaxpro_checkout_cart_add_suggestpage' => 'tm_ajaxpro_checkout_cart_add_with_cart_extended'));
} else {
// hide all popups, when on the suggest page
if (in_array('suggestpage_index_index', $handles)) {
$blockNames[] = 'content';
$blockNames[] = 'catalog_product_price_template';
$blockNames = $this->_replaceArrayValues($blockNames, array('ajaxpro_message' => false));
// need to remove all popup handles to prevent their appearence inside of content block
$handles = $this->_replaceArrayValues($handles, array('tm_ajaxpro_checkout_cart_add_*' => false, 'suggestpage_view' => false));
} elseif (in_array('tm_ajaxpro_checkout_cart_add_suggestpage', $handles)) {
// modify handles, when suggestpage should be shown in popup
$handles = array('default', 'tm_ajaxpro_checkout_cart_add_suggestpage');
$blockNames[] = 'content';
$blockNames[] = 'catalog_product_price_template';
}
}
$object->setBlockNames($blockNames);
$object->setHandles($handles);
}
示例3: clearCoreEmailQueueRecipientsAfterSave
/**
* Clear Mage_Core_Model_Email_Queue recipients after saving it
*
* @param Varien_Event_Observer $observer
*/
public function clearCoreEmailQueueRecipientsAfterSave(Varien_Event_Observer $observer)
{
$object = $observer->getObject();
if ($object instanceof Mage_Core_Model_Email_Queue) {
$object->clearRecipients();
}
}
示例4: _castObject
protected function _castObject(Varien_Event_Observer $observer)
{
$object = $observer->getObject();
if ($object instanceof Mage_Core_Model_Email_Template) {
return $object;
}
}
示例5: cmsPageSaveAfter
/**
* @param Varien_Event_Observer $observer
*/
public function cmsPageSaveAfter($observer)
{
/* @var $page Mage_Cms_Model_Page */
$page = $observer->getObject();
Mage::helper('typecms')->setupAttributes();
$pageType = Mage::getModel('typecms/page')->load($page->getId());
if (!$pageType->getId()) {
$pageType->setId($page->getId());
}
$pageType->setPageType($page->getPageType());
$data = $page->getData('typecms');
if (isset($data)) {
$pageType->addData($data);
}
$config = Mage::getSingleton('typecms/config');
$attributes = $config->getAttributes($pageType->getData('page_type'));
foreach ($attributes as $attributeCode => $attribute) {
if (in_array($attribute['type'], array('image', 'file'))) {
if ($pageType->getData($attributeCode . '_delete') == '1') {
self::deleteImage($pageType->getData($attributeCode));
$pageType->setData($attributeCode, null);
}
$file = $this->handleUpload($attributeCode, $attribute['type']);
if ($file && $file !== $pageType->getData($attributeCode)) {
self::deleteImage($pageType->getData($attributeCode));
}
if ($file) {
$pageType->setData($attributeCode, $file);
}
}
}
$pageType->save();
}
示例6: customerGroupSaveBefore
/**
* Handle data of new fields in customer group when saving
*
* @param Varien_Event_Observer $observer
*/
public function customerGroupSaveBefore($observer)
{
/** @var Mage_Customer_Model_Group $group */
$group = $observer->getObject();
$group->setData('request_vat_id', Mage::app()->getRequest()->getParam('request_vat_id'));
$group->setData('tax_class_id_vat_id', Mage::app()->getRequest()->getParam('tax_class_id_vat_id'));
}
示例7: reviewSaveAfter
/**
* Clear product cache after a review is saved
*
* @param Varien_Event_Observer $observer
*/
public function reviewSaveAfter(Varien_Event_Observer $observer)
{
$object = $observer->getObject();
$productCollection = $object->getProductCollection()->addAttributeToFilter('rt.review_id', array('eq' => $object->getId()));
foreach ($productCollection as $product) {
$product->cleanCache();
}
}
示例8: DefaultBlockVersion
/**
* Saves default blocks' versions
* @param $observer
*/
public function DefaultBlockVersion(Varien_Event_Observer $observer)
{
$block = $observer->getObject();
if (get_class($block) == "Mage_Cms_Model_Block") {
$collection = Mage::getModel('sc_cmsblockmanagement/versions')->getCollection();
$collection->addFieldToFilter('block_identifier', array("eq" => $block->getIdentifier()));
if (count($collection) == 0) {
$this->SaveBlockVersion($observer);
}
}
}
示例9: onUserLoadAfter
/**
* @param Varien_Event_Observer $observer
*/
public function onUserLoadAfter($observer)
{
/** @var Mage_Admin_Model_User $user */
$user = $observer->getObject();
if (!$user->getUserId()) {
// @bug???
return;
}
$resource = Mage::getSingleton('core/resource');
$query = 'SELECT signature FROM ' . $resource->getTableName('helpdesk/user') . ' WHERE user_id=' . $user->getUserId();
$data = $resource->getConnection('core_read')->fetchOne($query);
$user->setSignature($data);
}
示例10: deleteProduct
public function deleteProduct(Varien_Event_Observer $observer)
{
$product = $observer->getObject();
$storeCollection = Mage::getModel('core/store')->getCollection();
foreach ($storeCollection as $store) {
$idPath = sprintf('reviews/%d', $product->getId());
$rewrite = $this->getUrlRewrite();
$rewrite->setStoreId($store->getId())->loadByIdPath($idPath);
if ($rewrite->getId()) {
$rewrite->delete();
}
}
}
示例11: saveAdminToRoleRelation
/**
* Save relation of admin user to API2 role
*
* @param Varien_Event_Observer $observer
* @return void
*/
public function saveAdminToRoleRelation(Varien_Event_Observer $observer)
{
/** @var $user Mage_User_Model_User Object */
$user = $observer->getObject();
if ($user->hasData('api2_roles')) {
$roles = $user->getData('api2_roles');
if (!is_array($roles) || !isset($roles[0])) {
throw new Exception('API2 roles property has wrong data format.');
}
/** @var $resourceModel Mage_Api2_Model_Resource_Acl_Global_Role */
$resourceModel = Mage::getResourceModel('Mage_Api2_Model_Resource_Acl_Global_Role');
$resourceModel->saveAdminToRoleRelation($user->getId(), $roles[0]);
}
}
示例12: registerCustomer
/**
* creates a customer from facebook user
* @param Varien_Event_Observer $observer
* @throws Exception
*/
public function registerCustomer(Varien_Event_Observer $observer)
{
/** @var Alaa_FacebookConnect_Model_User $model */
$model = $observer->getObject();
if ($model instanceof Alaa_FacebookConnect_Model_User) {
$customer = null;
if ($model->isObjectNew()) {
$customer = $model->createCustomer();
}
if ($customer instanceof Mage_Customer_Model_Customer && $customer->getId()) {
$this->login($customer);
}
}
}
示例13: log
/**
* Log data
*
* @param Varien_Event_Observer $event
*/
public function log(Varien_Event_Observer $event)
{
$logActive = Mage::getStoreConfig(self::XML_PATH_MODEL_CACHE_ENABLED);
if (!$logActive) {
return;
}
$object = $event->getObject();
/* @var $object Mage_Core_Model_Abstract */
$class = get_class($object);
$id = $event->getValue();
if (!isset($this->data[$class])) {
$this->data[$class] = array();
}
if (!isset($this->data[$class][$id])) {
$this->data[$class][$id] = array();
}
$trace = debug_backtrace();
$this->data[$class][$id][] = $trace[5]['file'] . ':' . $trace[5]['line'];
$this->loadedModels++;
}
示例14: customerGroupSaveBefore
/**
* save typo3 group id
*
* @param Varien_Event_Observer $observer
*/
public function customerGroupSaveBefore($observer)
{
$observer->getObject()->setData('typo3_group_id', intval(Mage::app()->getRequest()->getParam('typo3_group_id')));
}
示例15: modelSaveCommitAfter
/**
* Processes models after save commit events
*
* @param Varien_Event_Observer $observer
* @return $this
*/
public function modelSaveCommitAfter(Varien_Event_Observer $observer)
{
$this->_getProcessor()->afterSave($observer->getObject());
return $this;
}