本文整理汇总了PHP中Varien_Event_Observer::getCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getCategory方法的具体用法?PHP Varien_Event_Observer::getCategory怎么用?PHP Varien_Event_Observer::getCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getCategory方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catalogCategoryMove
/**
* Observe the category move
*
* @param Varien_Event_Observer $observer Observer Instance
* @return void
*/
public function catalogCategoryMove(Varien_Event_Observer $observer)
{
$category = $observer->getCategory();
$dataModel = Mage::getModel('firegento_adminmonitoring/history_data', $category);
$diffModel = Mage::getModel('firegento_adminmonitoring/history_diff', $dataModel);
$eventData = array('object_id' => $dataModel->getObjectId(), 'object_type' => $dataModel->getObjectType(), 'content' => $dataModel->getSerializedContent(), 'content_diff' => $diffModel->getSerializedDiff(), 'action' => FireGento_AdminMonitoring_Helper_Data::ACTION_UPDATE);
Mage::dispatchEvent('firegento_adminmonitoring_log', $eventData);
}
示例2: menuGetCategoryMenuDataAfter
public function menuGetCategoryMenuDataAfter(Varien_Event_Observer $observer)
{
$category = $observer->getCategory();
$categoryMenuData = $observer->getCategoryMenuData();
if ($category->hasIconImage()) {
$imageUrl = $this->_prefixImageWithMediaPath($category->getIconImage());
$categoryMenuData->setIconImage($imageUrl);
}
}
示例3: prepareCategoryFacet
/**
* Install category facet into categories
*
* @param Varien_Event_Observer $observer Event data.
*
* @return Smile_VirtualCategories_Model_Observer
*/
public function prepareCategoryFacet(Varien_Event_Observer $observer)
{
// Retrieve filter and category from event
$filter = $observer->getFilter();
$category = $observer->getCategory();
// Retrieve query associated with the filter
$query = $filter->getLayer()->getProductCollection()->getSearchEngineQuery();
// Prepare facet query group
$queries = $this->_getVirtualRule($category)->getChildrenCategoryQueries(array(), false, 1);
$options = array('queries' => $queries, 'prefix' => 'categories_');
$query->addFacet('categories', 'queryGroup', $options);
$filter->setProductCollectionFacetSet(true);
return $this;
}
示例4: onCatalogCategorySaveAfter
/**
* catalog_category_save_after
*/
public function onCatalogCategorySaveAfter(Varien_Event_Observer $observer)
{
/** @var $category Mage_Catalog_Model_Category */
$category = $observer->getCategory();
if ($category->getId() == $category->getOrigData('entity_id')) {
return false;
}
/** @var $post Hackathon_Socialcommerce_Model_Messagetype_Singlepost */
$post = Mage::getModel('socialcommerce/messagetype_singlepost');
$post->setText($this->_getConfig()->getMessageNewCategory());
$post->setLink($category->getCategoryIdUrl());
$post->setPicture($category->getImageUrl());
/** @var $twitter Hackathon_Socialcommerce_Model_Adapter_Twitter */
$twitter = Mage::getModel('socialcommerce/adapter_twitter');
$twitter->sendSinglePost($post);
}
示例5: catalogCategoryPrepareSave
/**
* Append a custom block to the category.product.grid block.
*
* @param Varien_Event_Observer $observer
* @return void
*/
public function catalogCategoryPrepareSave(Varien_Event_Observer $observer)
{
$data = $observer->getRequest()->getParam('mep');
$category = $observer->getCategory();
$storeId = $observer->getRequest()->getParam('store');
if (!empty($data) && $category->getId() && $storeId) {
foreach ($data as $id => $value) {
$id = ltrim($id, 'mapping_');
$model = Mage::getModel('mep/attribute_mapping')->load($id);
$model->load($id);
try {
$model->setOption(array('value' => array($category->getId() => array($storeId => $value))));
$model->save();
} catch (Exception $e) {
Mage::logException($e);
}
}
}
}
示例6: catalogCategoryPrepareSave
/**
* Cache data after save in category tab
*
* @param Varien_Event_Observer $observer observed object
*/
public function catalogCategoryPrepareSave(Varien_Event_Observer $observer)
{
$multiSelectArray = $observer->getCategory()->getDealUpdateDays();
if (!empty($multiSelectArray)) {
$multiSelectStr = implode(",", $multiSelectArray);
$observer->getCategory()->setDealUpdateDays($multiSelectStr)->save();
}
}
示例7: saveCategoryTop
public function saveCategoryTop(Varien_Event_Observer $observer)
{
$dat = $observer->getRequest()->getParams();
$categoryId = $observer->getCategory()->getId();
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$data['category_id'] = $categoryId;
if (@$dat['active_product']) {
$data['active_product'] = @$dat['active_product'];
} else {
$data['active_product'] = 0;
}
$data['numbers_product'] = @$dat['numbers_product'];
if (@$dat['active_width']) {
$data['active_width'] = @$dat['active_width'];
} else {
$data['active_width'] = 0;
}
$data['width_level'] = @$dat['width_level'];
if (@$dat['active_static_block_top']) {
$data['active_static_block_top'] = @$dat['active_static_block_top'];
} else {
$data['active_static_block_top'] = 0;
}
$data['static_block_top'] = @$dat['static_block_top'];
if (@$dat['active_static_block']) {
$data['active_static_block'] = $dat['active_static_block'];
} else {
$data['active_static_block'] = 0;
}
if (@$dat['active_static_block_left']) {
$data['active_static_block_left'] = @$dat['active_static_block_left'];
} else {
$data['active_static_block_left'] = 0;
}
$data['static_block_left'] = @$dat['static_block_left'];
if (@$dat['active_static_block_bottom']) {
$data['active_static_block_bottom'] = @$dat['active_static_block_bottom'];
} else {
$data['active_static_block_bottom'] = 0;
}
$data['static_block_bottom'] = @$dat['static_block_bottom'];
if (@$dat['active_static_block_right']) {
$data['active_static_block_right'] = @$dat['active_static_block_right'];
} else {
$data['active_static_block_right'] = 0;
}
$data['static_block_right'] = @$dat['static_block_right'];
if (@$dat['active_label']) {
$data['active_label'] = @$dat['active_label'];
} else {
$data['active_label'] = 0;
}
$data['label'] = @$dat['label'];
if (@$dat['active_thumbail']) {
$data['active_thumbail'] = @$dat['active_thumbail'];
} else {
$data['active_thumbail'] = 0;
}
$data['level_column_count'] = @$dat['level_column_count'];
if (@$dat['hidden_menutop']) {
$data['hidden_menutop'] = @$dat['hidden_menutop'];
} else {
$data['hidden_menutop'] = 0;
}
if (@$dat['category_children']) {
$data['category_children'] = @$dat['category_children'];
} else {
$data['category_children'] = 0;
}
if (@$dat['width_block_left']) {
$data['width_block_left'] = @$dat['width_block_left'];
} else {
$data['width_block_left'] = 0;
}
if (@$dat['width_block_right']) {
$data['width_block_right'] = @$dat['width_block_right'];
} else {
$data['width_block_right'] = 0;
}
if (@$dat['width_children']) {
$data['width_children'] = @$dat['width_children'];
} else {
$data['width_children'] = 0;
}
if (@$dat['font-color']) {
$data['font-color'] = @$dat['font-color'];
} else {
$data['font-color'] = '';
}
if (@$dat['background-color']) {
$data['background-color'] = @$dat['background-color'];
} else {
$data['background-color'] = '';
}
if (@$dat['hide_menutop']) {
$data['hide_menutop'] = @$dat['hide_menutop'];
} else {
$data['hide_menutop'] = 0;
}
$model = Mage::getModel('megamenu/megamenu');
//.........这里部分代码省略.........
示例8: deleteCategoryCustomRedirects
/**
* Listener for before category delete event. Deletes category custom redirects.
* Needed because of http://bugs.mysql.com/bug.php?id=11472
* @param Varien_Event_Observer $observer
*/
public function deleteCategoryCustomRedirects(Varien_Event_Observer $observer)
{
if ((string) $this->_app->getConfig()->getNode(Enterprise_UrlRewrite_Model_Index_Observer::XML_PATH_REDIRECT_URL_SUFFIX_UPDATE_ON_SAVE)) {
return;
}
/** @var Mage_Catalog_Model_Category $category */
$category = $observer->getCategory();
$ids = $category->getResource()->getChildrenIds($category, true);
$ids[] = $category->getId();
/** @var Enterprise_UrlRewrite_Model_Resource_Redirect $redirects */
$redirects = $this->_factory->getResourceModel('enterprise_urlrewrite/redirect');
$redirects->deleteByCategoryIds($ids);
}
示例9: getUrl
public function getUrl(Varien_Event_Observer $observer)
{
$category = $observer->getCategory();
$url = Mage::helper('conversionpro')->getResultUrl($category->getName());
$category->setData('url', $url);
}
示例10: catalogCategorySaveAfter
/**
* Save category draft data for new categories
*
* @param Varien_Event_Observer $observer
*/
public function catalogCategorySaveAfter(Varien_Event_Observer $observer)
{
if ($this->_shouldPublishCategory()) {
return;
}
/** @var Mage_Catalog_Model_Category $category */
$category = $observer->getCategory();
if ($category->getOriginalIsActive()) {
/** @var $changesObject Firegento_FlexCms_Model_Category_Changes */
$changesObject = Mage::helper('firegento_flexcms')->getChangesObject($category);
$changesObject->setCategoryId($category->getId());
$changesObject->setStoreId($category->getStoreId());
$changesObject->setAdminUserId($this->_getAdminUserId());
$changesObject->setChanges(array('is_active' => 1));
$changesObject->save();
}
}
示例11: catalogProductLoadAfter
public function catalogProductLoadAfter(Varien_Event_Observer $observer)
{
if (Mage::getStoreConfig('sitemaster_categorybanner/general/active')) {
$category = $observer->getCategory();
$maincat = explode("/", $category->getPath());
if ($maincat[2]) {
switch ($maincat[2]) {
case 32:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menumasla_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menumasla_staticblockid'));
}
break;
case 149:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menuorigin_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menuorigin_staticblockid'));
}
break;
case 33:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menusmazki_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menusmazki_staticblockid'));
}
break;
case 34:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menufiltra_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menufiltra_staticblockid'));
}
break;
case 35:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menuautohimia_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menuautohimia_staticblockid'));
}
break;
case 36:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menuautocosm_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menuautocosm_staticblockid'));
}
break;
case 37:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menuzapchasti_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menuzapchasti_staticblockid'));
}
break;
case 38:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menushini_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menushini_staticblockid'));
}
break;
case 7:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menuactii_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menuactii_staticblockid'));
}
break;
default:
if (Mage::getStoreConfig('sitemaster_categorybanner/general/menumasla_staticblockid') != '-1') {
$category->setDisplayMode('PRODUCTS_AND_PAGE');
$category->setlanding_page(Mage::getStoreConfig('sitemaster_categorybanner/general/menumasla_staticblockid'));
}
}
}
}
}
示例12: catalogCategorySaveAfter
/**
* Set the html block cache to disabled/invalid when groupscatalog visibility settings
* have changed because the top menu is cached.
*
* This might be better suited to go into the indexer, but that seems very unclean to mix
* the indexer logic with the cache logic. So for now I'll put it here.
*
* @param Varien_Event_Observer $observer
* @return void
*/
public function catalogCategorySaveAfter(Varien_Event_Observer $observer)
{
/* @var $category Mage_Catalog_Model_Category */
$category = $observer->getCategory();
$helper = $this->_getHelper();
// If the module isn't disabled on a global scale
if ($helper->isModuleActive($category->getStore(), false) && !$this->_isDisabledOnRequest()) {
if ($category->dataHasChangedFor(Netzarbeiter_GroupsCatalog2_Helper_Data::HIDE_GROUPS_ATTRIBUTE)) {
if ($helper->getConfig('auto_refresh_block_cache')) {
// Only refresh the category block cache: Mage_Catalog_Model_Category::CACHE_TAG
Mage::app()->cleanCache(array(Mage_Catalog_Model_Category::CACHE_TAG));
} else {
Mage::app()->getCacheInstance()->invalidateType(Mage_Core_Block_Abstract::CACHE_GROUP);
}
}
}
}