Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Adminhtml_Block_Sitemap
  • Mage_Adminhtml_Block_Sitemap_Grid_Renderer_Action
  • Mage_Adminhtml_Block_Sitemap_Grid_Renderer_Link
  • Mage_Adminhtml_Block_Sitemap_Grid_Renderer_Time
  • Mage_Adminhtml_SitemapController
  • Mage_Sitemap_Helper_Data
  • Mage_Sitemap_Model_Mysql4_Catalog_Category
  • Mage_Sitemap_Model_Mysql4_Catalog_Product
  • Mage_Sitemap_Model_Mysql4_Cms_Page
  • Mage_Sitemap_Model_Mysql4_Sitemap
  • Mage_Sitemap_Model_Mysql4_Sitemap_Collection
  • Mage_Sitemap_Model_Observer
  • Mage_Sitemap_Model_Resource_Catalog_Category
  • Mage_Sitemap_Model_Resource_Catalog_Product
  • Mage_Sitemap_Model_Resource_Cms_Page
  • Mage_Sitemap_Model_Resource_Sitemap
  • Mage_Sitemap_Model_Resource_Sitemap_Collection
  • Mage_Sitemap_Model_Sitemap
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Sitemap
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Sitemap module observer
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_Sitemap
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Sitemap_Model_Observer
 36: {
 37: 
 38:     /**
 39:      * Enable/disable configuration
 40:      */
 41:     const XML_PATH_GENERATION_ENABLED = 'sitemap/generate/enabled';
 42: 
 43:     /**
 44:      * Cronjob expression configuration
 45:      */
 46:     const XML_PATH_CRON_EXPR = 'crontab/jobs/generate_sitemaps/schedule/cron_expr';
 47: 
 48:     /**
 49:      * Error email template configuration
 50:      */
 51:     const XML_PATH_ERROR_TEMPLATE  = 'sitemap/generate/error_email_template';
 52: 
 53:     /**
 54:      * Error email identity configuration
 55:      */
 56:     const XML_PATH_ERROR_IDENTITY  = 'sitemap/generate/error_email_identity';
 57: 
 58:     /**
 59:      * 'Send error emails to' configuration
 60:      */
 61:     const XML_PATH_ERROR_RECIPIENT = 'sitemap/generate/error_email';
 62: 
 63:     /**
 64:      * Generate sitemaps
 65:      *
 66:      * @param Mage_Cron_Model_Schedule $schedule
 67:      */
 68:     public function scheduledGenerateSitemaps($schedule)
 69:     {
 70:         $errors = array();
 71: 
 72:         // check if scheduled generation enabled
 73:         if (!Mage::getStoreConfigFlag(self::XML_PATH_GENERATION_ENABLED)) {
 74:             return;
 75:         }
 76: 
 77:         $collection = Mage::getModel('sitemap/sitemap')->getCollection();
 78:         /* @var $collection Mage_Sitemap_Model_Mysql4_Sitemap_Collection */
 79:         foreach ($collection as $sitemap) {
 80:             /* @var $sitemap Mage_Sitemap_Model_Sitemap */
 81: 
 82:             try {
 83:                 $sitemap->generateXml();
 84:             }
 85:             catch (Exception $e) {
 86:                 $errors[] = $e->getMessage();
 87:             }
 88:         }
 89: 
 90:         if ($errors && Mage::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT)) {
 91:             $translate = Mage::getSingleton('core/translate');
 92:             /* @var $translate Mage_Core_Model_Translate */
 93:             $translate->setTranslateInline(false);
 94: 
 95:             $emailTemplate = Mage::getModel('core/email_template');
 96:             /* @var $emailTemplate Mage_Core_Model_Email_Template */
 97:             $emailTemplate->setDesignConfig(array('area' => 'backend'))
 98:                 ->sendTransactional(
 99:                     Mage::getStoreConfig(self::XML_PATH_ERROR_TEMPLATE),
100:                     Mage::getStoreConfig(self::XML_PATH_ERROR_IDENTITY),
101:                     Mage::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT),
102:                     null,
103:                     array('warnings' => join("\n", $errors))
104:                 );
105: 
106:             $translate->setTranslateInline(true);
107:         }
108:     }
109: }
110: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0