Beispiel #1
0
 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Varien_Gdata_Gshopping_Entry $entry
  * @return Varien_Gdata_Gshopping_Entry
  */
 public function convertAttribute($product, $entry)
 {
     $url = $product->getProductUrl(false);
     if ($url) {
         if (!Mage::getStoreConfigFlag('web/url/use_store')) {
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         $links = $entry->getLink();
         if (!is_array($links)) {
             $links = array();
         }
         $link = $entry->getService()->newLink();
         $link->setHref($url);
         $link->setRel('alternate');
         $link->setType('text/html');
         if ($product->getName()) {
             $link->setTitle($product->getName());
         }
         $links[0] = $link;
         $entry->setLink($links);
     }
     return $entry;
 }
Beispiel #2
0
 public function getFeedUrl()
 {
     if (is_null($this->_feedUrl)) {
         $this->_feedUrl = (Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://') . Mage::getStoreConfig(self::XML_FEED_URL_PATH);
     }
     return $this->_feedUrl;
 }
             $category = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIdFilter($id)->getFirstItem();
             return $category;
         }
     }
     return false;
 }
 /**
  * return "" if module is not activated in settings
Beispiel #4
0
 /**
  * Generate sitemaps
  *
  * @param Mage_Cron_Model_Schedule $schedule
  */
 public function scheduledGenerateSitemaps($schedule)
 {
     $errors = array();
     // check if scheduled generation enabled
     if (!Mage::getStoreConfigFlag(self::XML_PATH_GENERATION_ENABLED)) {
         return;
     }
     $collection = Mage::getModel('sitemap/sitemap')->getCollection();
     /* @var $collection Mage_Sitemap_Model_Mysql4_Sitemap_Collection */
     foreach ($collection as $sitemap) {
         /* @var $sitemap Mage_Sitemap_Model_Sitemap */
         try {
             $sitemap->generateXml();
         } catch (Exception $e) {
             $errors[] = $e->getMessage();
         }
     }
     if ($errors && Mage::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT)) {
         $translate = Mage::getSingleton('core/translate');
         /* @var $translate Mage_Core_Model_Translate */
         $translate->setTranslateInline(false);
         $emailTemplate = Mage::getModel('core/email_template');
         /* @var $emailTemplate Mage_Core_Model_Email_Template */
         $emailTemplate->setDesignConfig(array('area' => 'backend'))->sendTransactional(Mage::getStoreConfig(self::XML_PATH_ERROR_TEMPLATE), Mage::getStoreConfig(self::XML_PATH_ERROR_IDENTITY), Mage::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT), null, array('warnings' => join("\n", $errors)));
         $translate->setTranslateInline(true);
     }
 }
Beispiel #5
0
 /**
  * Check whether or not the module output is enabled
  *
  * Because many module blocks belong to Adminhtml module,
  * the feature "Disable module output" doesn't cover Admin area
  *
  * @param string $moduleName Full module name
  * @return boolean
  */
 public function isOutputEnabled($moduleName = null)
 {
     if ($moduleName === null) {
         $moduleName = $this->getModuleName();
     }
     return !Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName);
 }
Beispiel #6
0
 /**
  * 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();
             }
         }
     }
 }
Beispiel #7
0
 protected function _toHtml()
 {
     if (Mage::getStoreConfigFlag('rewards/autointegration/product_view_warnguest')) {
         return parent::_toHtml();
     }
     return '';
 }
 public function indexAction()
 {
     $storeId = $this->getRequest()->getParam('store');
     $groupId = $this->getRequest()->getParam('group');
     if (null === $storeId || null === $groupId) {
         if (null === $storeId) {
             $storeId = Mage::getSingleton('admin/session')->getCmsLastViewedStore();
             if (null === $storeId) {
                 if (Mage::app()->isSingleStoreMode()) {
                     $storeId = Mage::app()->getDefaultStoreView()->getId();
                 } else {
                     $storeId = 0;
                 }
             }
         }
         if (!$groupId) {
             $groupId = Mage_Customer_Model_Group::NOT_LOGGED_IN_ID;
         }
         $this->_redirect('*/*/', array('store' => $storeId, 'group' => $groupId));
         return;
     }
     Mage::getSingleton('admin/session')->setCmsLastViewedStore($storeId);
     if (!Mage::getStoreConfigFlag('cms/clever/permissions_enabled')) {
         $this->_getSession()->addNotice($this->__('Permissions are currently disabled. To enable permissions, go to System > Configuration > Content Management > Clever CMS.'));
     }
     $this->_title($this->__('CMS'))->_title($this->__('Pages'))->_title($this->__('Manage Content Permissions'));
     $this->_initAction();
     $this->renderLayout();
 }
 public function showMessage($message, $isError = true, $showEachTime = false)
 {
     if (!Mage::getStoreConfigFlag('ampromo/messages/errors') && $isError) {
         return;
     }
     if (!Mage::getStoreConfigFlag('ampromo/messages/success') && !$isError) {
         return;
     }
     // show on cart page only
     $all = Mage::getSingleton('checkout/session')->getMessages(false)->toString();
     if (false !== strpos($all, $message)) {
         return;
     }
     if ($isError && isset($_GET['debug'])) {
         Mage::getSingleton('checkout/session')->addError($message);
     } else {
         $arr = Mage::getSingleton('checkout/session')->getAmpromoMessages();
         if (!is_array($arr)) {
             $arr = array();
         }
         if (!in_array($message, $arr) || $showEachTime) {
             Mage::getSingleton('checkout/session')->addNotice($message);
             $arr[] = $message;
             Mage::getSingleton('checkout/session')->setAmpromoMessages($arr);
         }
     }
 }
Beispiel #10
0
 /**
  * Check if the included Zurb Foundation should be used
  *
  * @return  bool
  */
 public function useIncludedZurb()
 {
     if (Mage::getStoreConfigFlag(self::XML_PATH_USE_INCLUDED_ZURB)) {
         return true;
     }
     return false;
 }
Beispiel #11
0
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getStoreConfigFlag('productlist/general_setting/show')) {
         $this->norouteAction();
     }
 }
Beispiel #12
0
 public function __construct()
 {
     $availableByIP = true;
     if (Mage::getStoreConfig('msp/msp_payafter/ip_check')) {
         if ($this->_isTestMode()) {
             $data = Mage::getStoreConfig('msp/msp_payafter/ip_filter_test');
         } else {
             $data = Mage::getStoreConfig('msp/msp_payafter/ip_filter');
         }
         if (!in_array($_SERVER["REMOTE_ADDR"], explode(';', $data))) {
             $availableByIP = false;
         }
     }
     $currencies = explode(',', Mage::getStoreConfig('msp/' . $this->_code . '/allowed_currency'));
     $isAllowConvert = Mage::getStoreConfigFlag('msp/settings/allow_convert_currency');
     if ($isAllowConvert) {
         $availableByCurrency = true;
     } else {
         if (in_array(Mage::app()->getStore()->getCurrentCurrencyCode(), $currencies)) {
             $availableByCurrency = true;
         } else {
             $availableByCurrency = false;
         }
     }
     $this->_canUseCheckout = $availableByIP && $availableByCurrency;
 }
Beispiel #13
0
 /**
  * When caching a page simply generate and cache a random value as the ETag
  *
  * @param Mage_Core_Controller_Response_Http $response
  * @param $lifetime
  */
 public function httpResponseSendBefore(Mage_Core_Controller_Response_Http $response, $lifetime)
 {
     $useEtags = Mage::getStoreConfigFlag('system/diehard/use_etags');
     $cacheKey = $this->getCacheKey();
     // Use existing cache data if it exists in case there are multiple upstream proxies
     // If a record exists then any content generated at the time the record was is assumed to not be stale
     if (!($cacheData = Mage::app()->loadCache($cacheKey))) {
         $fullActionName = $this->helper()->getFullActionName();
         if ($useEtags) {
             $cacheData = $fullActionName . ':' . sha1(microtime() . mt_rand());
         } else {
             $cacheData = $fullActionName . ':' . $this->_rfc1123Date();
         }
         $tags = $this->helper()->getTags();
         $tags[] = Cm_Diehard_Helper_Data::CACHE_TAG;
         Mage::app()->saveCache($cacheData, $cacheKey, $tags, $lifetime);
     }
     list($fullActionName, $cacheData) = explode(':', $cacheData, 2);
     // Set headers so the page is cached with the ETag/Last-Modified value for invalidation
     session_cache_limiter('');
     $cacheControl = sprintf(Mage::getStoreConfig('system/diehard/cachecontrol'), $lifetime);
     $response->setHeader('Cache-Control', $cacheControl, true);
     $response->setHeader('Expires', $this->_rfc1123Date(time() + $lifetime), true);
     if ($useEtags) {
         $response->setHeader('ETag', 'W/"' . $cacheData . '"', true);
     } else {
         $response->setHeader('Last-Modified', $cacheData, true);
     }
 }
Beispiel #14
0
 /**
  * Get crosssell items
  *
  * @return array
  */
 public function getItemCollection()
 {
     if (!Mage::helper('conversionpro')->isActiveEngine() || !Mage::getStoreConfigFlag('conversionpro/crosssell_settings/upsell_enabled')) {
         return parent::getItemCollection();
     }
     if (is_null($this->_itemCollection)) {
         $lastAdded = null;
         //This code path covers the 2 cases - product page and shopping cart
         if ($this->getProduct() != null) {
             $lastAdded = $this->getProduct()->getId();
         } else {
             $cartProductIds = $this->_getCartProductIds();
             $lastAdded = null;
             for ($i = count($cartProductIds) - 1; $i >= 0; $i--) {
                 $id = $cartProductIds[$i];
                 $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($id);
                 if (empty($parentIds)) {
                     $lastAdded = $id;
                     break;
                 }
             }
         }
         $crossSellIds = Mage::helper('conversionpro')->getSalespersonCrossSellApi()->getRecommendationsIds($lastAdded);
         $this->_maxItemCount = Mage::getStoreConfig('conversionpro/crosssell_settings/upsell_limit');
         $this->_itemCollection = $this->_getCollection()->addAttributeToFilter('entity_id', array('in' => $crossSellIds));
     }
     return $this->_itemCollection;
 }
 /**
  * Submit new review action
  *
  */
 public function postAction()
 {
     if (Mage::getStoreConfigFlag(self::XML_PATH_PRC_ENABLED)) {
         try {
             $post = $this->getRequest()->getPost();
             if ($post) {
                 //include reCaptcha library
                 require_once Mage::getModuleDir('', 'OlegKoval_ProductReviewCaptcha') . DS . 'Helper' . DS . 'recaptchalib.php';
                 //validate captcha
                 $privatekey = Mage::getStoreConfig(self::XML_PATH_PRC_PRIVATE_KEY);
                 $remote_addr = $this->getRequest()->getServer('REMOTE_ADDR');
                 $captcha = recaptcha_check_answer($privatekey, $remote_addr, $post["recaptcha_challenge_field"], $post["recaptcha_response_field"]);
                 if (!$captcha->is_valid) {
                     throw new Exception($this->__("The reCAPTCHA wasn't entered correctly."), 1);
                 }
             } else {
                 throw new Exception('', 1);
             }
         } catch (Exception $e) {
             if (strlen($e->getMessage()) > 0) {
                 Mage::getSingleton('core/session')->addError($this->__($e->getMessage()));
                 Mage::getSingleton('core/session')->setFormData($post);
             }
             if ($redirectUrl = Mage::getSingleton('review/session')->getRedirectUrl(true)) {
                 $this->_redirectUrl($redirectUrl);
                 return;
             }
             $this->_redirectReferer();
             return;
         }
     }
     //everything is OK - call parent action
     parent::postAction();
 }
Beispiel #16
0
 /**
  *
  * @param mixed $store
  * @return bool
  */
 public function isPiwikAnalyticsAvailable($store = null)
 {
     $siteId = Mage::getStoreConfig(self::XML_PATH_SITE, $store);
     //$installPath = Mage::getStoreConfig(self::XML_PATH_INSTALL, $store);
     //return $siteId && $installPath && Mage::getStoreConfigFlag(self::XML_PATH_ACTIVE, $store);
     return $siteId && Mage::getStoreConfigFlag(self::XML_PATH_ACTIVE, $store);
 }
Beispiel #17
0
 public function _toHtml()
 {
     if (Mage::getStoreConfigFlag('payment/paypaluk_express/active') && Mage::getSingleton('checkout/session')->getQuote()->validateMinimumAmount()) {
         return parent::_toHtml();
     }
     return '';
 }
Beispiel #18
0
 private function _initConfiguration()
 {
     if (!$this->config) {
         # Load configuration:
         $this->config = array('IMPORT_SKIP_HEADER' => Mage::getStoreConfigFlag('orderstatusimport/processor_csv/skip_header'), 'IMPORT_DELIMITER' => Mage::getStoreConfig('orderstatusimport/processor_csv/delimiter'), 'IMPORT_ENCLOSURE' => Mage::getStoreConfig('orderstatusimport/processor_csv/enclosure'), 'IMPORT_SHIPPED_ONE_FIELD' => Mage::getStoreConfigFlag('orderstatusimport/processor_csv/shipped_one_field'));
         # Get mapping model
         $this->mappingModel = Mage::getModel('orderstatusimport/processor_mapping_fields');
         $this->mappingModel->setDataPath('orderstatusimport/processor_csv/import_mapping');
         # Load mapping
         $this->mapping = $this->mappingModel->getMappingConfig();
         if ($this->mapping->getOrderNumber() == null) {
             Mage::throwException('Please configure the CSV processor in the configuration section of the Tracking Number Import Module. The order number index field may not be empty and must be mapped.');
         }
         if ($this->config['IMPORT_DELIMITER'] == '') {
             Mage::throwException('Please configure the CSV processor in the configuration section of the Tracking Number Import Module. The Field Delimiter may not be empty.');
         }
         if ($this->config['IMPORT_ENCLOSURE'] == '') {
             $this->config['IMPORT_ENCLOSURE'] = '"';
         }
         if (strtolower($this->config['IMPORT_DELIMITER']) == 'tab' || $this->config['IMPORT_DELIMITER'] == '\\t' || $this->config['IMPORT_DELIMITER'] == chr(9)) {
             $this->config['IMPORT_DELIMITER'] = "\t";
         }
         if (strtolower($this->config['IMPORT_DELIMITER']) == 'flf') {
             $this->config['IMPORT_FIXED_LENGTH_FORMAT'] = true;
         } else {
             $this->config['IMPORT_FIXED_LENGTH_FORMAT'] = false;
         }
     }
 }
 public function send()
 {
     try {
         $data = $this->grabData();
         $url = 'https://ebizmarts.com/sagepaysuite_tracker.php';
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, $url);
         curl_setopt($curl, CURLOPT_POST, 1);
         curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
         $sslversion = Mage::getStoreConfig('payment/sagepaysuite/curl_ssl_version');
         curl_setopt($curl, CURLOPT_SSLVERSION, $sslversion);
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($curl, CURLOPT_TIMEOUT, 4);
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
         if (Mage::getStoreConfigFlag('payment/sagepaysuite/curl_proxy') == 1) {
             curl_setopt($curl, CURLOPT_PROXY, Mage::getStoreConfig('payment/sagepaysuite/curl_proxy_port'));
         }
         $response = curl_exec($curl);
         if (!curl_error($curl)) {
             return TRUE;
         }
         return FALSE;
     } catch (Exception $e) {
         Sage_Log::logException($e);
         return FALSE;
     }
 }
Beispiel #20
0
 /**
  * Check is enable catalog product for store
  *
  * @param mixed $store
  * @return bool
  */
 public function isEnabled($store = null)
 {
     if (Mage::app()->getStore($store)->isAdmin()) {
         return false;
     }
     return Mage::getStoreConfigFlag(self::XML_PATH_USE_PRODUCT_FLAT, $store);
 }
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)) {
         $this->norouteAction();
     }
 }
Beispiel #22
0
 /**
  * Can be used in regular checkout
  *
  * @return bool
  */
 public function canUseCheckout()
 {
     if (Mage::getStoreConfigFlag('payment/hosted_pro/active') && !Mage::getStoreConfigFlag('payment/hosted_pro/display_ec')) {
         return false;
     }
     return parent::canUseCheckout();
 }
Beispiel #23
0
 /**
  * Render RSS
  *
  * @return string
  */
 protected function _toHtml()
 {
     $newUrl = Mage::getUrl('rss/catalog/notifystock');
     /* @var $helper Mage_Rss_Helper_Data */
     $helper = Mage::helper('Mage_Rss_Helper_Data');
     $title = $helper->__('Low Stock Products');
     $rssObj = Mage::getModel('Mage_Rss_Model_Rss');
     $data = array('title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8');
     $rssObj->_addHeader($data);
     $configManageStock = (int) Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
     $globalNotifyStockQty = (double) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY);
     $helper->disableFlat();
     /* @var $product Mage_Catalog_Model_Product */
     $product = Mage::getModel('Mage_Catalog_Model_Product');
     /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
     $collection = $product->getCollection();
     $stockItemTable = $collection->getTable('cataloginventory_stock_item');
     $stockItemWhere = '({{table}}.low_stock_date is not null) ' . " AND ( ({{table}}.use_config_manage_stock=1 AND {$configManageStock}=1)" . " AND {{table}}.qty < " . "IF({$stockItemTable}.`use_config_notify_stock_qty`, {$globalNotifyStockQty}, {{table}}.notify_stock_qty)" . ' OR ({{table}}.use_config_manage_stock=0 AND {{table}}.manage_stock=1) )';
     $collection->addAttributeToSelect('name', true)->joinTable('cataloginventory_stock_item', 'product_id=entity_id', array('qty' => 'qty', 'notify_stock_qty' => 'notify_stock_qty', 'use_config' => 'use_config_notify_stock_qty', 'low_stock_date' => 'low_stock_date'), $stockItemWhere, 'inner')->setOrder('low_stock_date');
     $collection->addAttributeToFilter('status', array('in' => Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getVisibleStatusIds()));
     Mage::dispatchEvent('rss_catalog_notify_stock_collection_select', array('collection' => $collection));
     /*
     using resource iterator to load the data one by one
     instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
     */
     Mage::getSingleton('Mage_Core_Model_Resource_Iterator')->walk($collection->getSelect(), array(array($this, 'addNotifyItemXmlCallback')), array('rssObj' => $rssObj, 'product' => $product, 'globalQty' => $globalNotifyStockQty));
     return $rssObj->createRssXml();
 }
Beispiel #24
0
 /**
  * If Integrated search is installed, redirect if enabled
  *
  * @return $this
  */
 public function preDispatch()
 {
     if (Mage::helper('wordpress')->isAddonInstalled('IntegratedSearch') && Mage::getStoreConfigFlag('wordpress/integratedsearch/blog')) {
         $this->_forceForwardViaException('index', 'result', 'catalogsearch', array('q' => Mage::helper('wordpress/router')->getTrimmedUri('search')));
     }
     return parent::preDispatch();
 }
 /**
  * Create Backup
  *
  * @return Mage_Log_Model_Cron
  */
 public function scheduledBackup()
 {
     if (!Mage::getStoreConfigFlag(self::XML_PATH_BACKUP_ENABLED)) {
         return $this;
     }
     if (Mage::getStoreConfigFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE)) {
         Mage::helper('backup')->turnOnMaintenanceMode();
     }
     $type = Mage::getStoreConfig(self::XML_PATH_BACKUP_TYPE);
     $this->_errors = array();
     try {
         $backupManager = Mage_Backup::getBackupInstance($type)->setBackupExtension(Mage::helper('backup')->getExtensionByType($type))->setTime(time())->setBackupsDir(Mage::helper('backup')->getBackupsDir());
         Mage::register('backup_manager', $backupManager);
         if ($type != Mage_Backup_Helper_Data::TYPE_DB) {
             $backupManager->setRootDir(Mage::getBaseDir())->addIgnorePaths(Mage::helper('backup')->getBackupIgnorePaths());
         }
         $backupManager->create();
         Mage::log(Mage::helper('backup')->getCreateSuccessMessageByType($type));
     } catch (Exception $e) {
         $this->_errors[] = $e->getMessage();
         $this->_errors[] = $e->getTrace();
         Mage::log($e->getMessage(), Zend_Log::ERR);
         Mage::logException($e);
     }
     if (Mage::getStoreConfigFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE)) {
         Mage::helper('backup')->turnOffMaintenanceMode();
     }
     return $this;
 }
Beispiel #26
0
 public function isShow()
 {
     if (is_null($this->_show)) {
         $this->_show = $this->helper('aitcheckout')->isModuleEnabled('AdjustWare_Deliverydate') && Mage::getStoreConfigFlag('checkout/adjdeliverydate/enabled');
     }
     return $this->_show;
 }
Beispiel #27
0
 /**
  * Check if price slider is enabled
  * 
  * @return boolean
  */
 public function isPriceSliderEnabled()
 {
     if (!$this->isEnabled()) {
         return false;
     }
     return Mage::getStoreConfigFlag('catalin_seo/catalog/price_slider');
 }
Beispiel #28
0
 public function prepareForm($observer)
 {
     $page = Mage::registry('cms_page');
     $form = $observer->getEvent()->getForm();
     $includeInMenuDisabled = $urlKeyDisabled = false;
     // add our 'url_key' field so that users can set a URL identifier independent of the CMS page title
     if ($page->getPageId()) {
         $store = Mage::app()->getStore($page->getStoreId());
         $storeCode = null;
         if (Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL)) {
             $storeCode = $store->getCode() . '/';
         }
         // disable the 'url key' and 'include in menu' configuration options for the root CMS page
         if ($page->isRoot()) {
             $includeInMenuDisabled = $urlKeyDisabled = true;
         }
     }
     $form->getElement('base_fieldset')->addField('url_key', 'text', array('name' => 'url_key', 'label' => Mage::helper('cms')->__('URL Key'), 'title' => Mage::helper('cms')->__('URL Key'), 'note' => Mage::helper('cms')->__('Leave blank for automatic generation.<br />URL is relative to parent URL. Current URL: %s', $page->getUrl()), 'value' => $page->getIdentifier(), 'disabled' => $urlKeyDisabled));
     if (!Mage::app()->isSingleStoreMode() && $page->getStoreId() == 0) {
         $form->getElement('base_fieldset')->removeField('stores');
         $form->getElement('base_fieldset')->addField('stores', 'multiselect', array('name' => 'stores[]', 'label' => Mage::helper('cms')->__('Store View'), 'title' => Mage::helper('cms')->__('Store View'), 'required' => false, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm()));
     }
     $form->getElement('base_fieldset')->addField('include_in_menu', 'select', array('name' => 'include_in_menu', 'label' => Mage::helper('cms')->__('Include in Navigation Menu'), 'title' => Mage::helper('cms')->__('Include in Navigation Menu'), 'note' => Mage::helper('cms')->__('Set <em>clever</em> theme and <em>default</em> package to have an example of navigation'), 'values' => array('1' => Mage::helper('adminhtml')->__('Yes'), '0' => Mage::helper('adminhtml')->__('No')), 'disabled' => $includeInMenuDisabled));
     $form->getElement('base_fieldset')->removeField('identifier')->removeField('store_id');
     $form->addField('store_id', 'hidden', array('name' => 'store'));
     $form->addField('parent_id', 'hidden', array('name' => 'parent'));
     $form->addField('identifier', 'hidden', array('name' => 'identifier'));
     if (null === $page->getIncludeInMenu()) {
         $page->setIncludeInMenu(true);
     }
 }
 public function getPdf($invoices = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     $pdf = new Zend_Pdf();
     $this->_setPdf($pdf);
     $style = new Zend_Pdf_Style();
     $this->_setFontBold($style, 10);
     foreach ($invoices as $invoice) {
         if ($invoice->getStoreId()) {
             Mage::app()->getLocale()->emulate($invoice->getStoreId());
         }
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
         $pdf->pages[] = $page;
         $order = $invoice->getOrder();
         /* Add image */
         $this->insertLogo($page, $invoice->getStore());
         /* Add address */
         $this->insertAddress($page, $invoice->getStore());
         /* Add head */
         $this->insertOrder($page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId()));
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
         $this->_setFontRegular($page);
         $page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35, 780, 'UTF-8');
         /* Add table */
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
         $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
         $page->setLineWidth(0.5);
         $page->drawRectangle(25, $this->y, 570, $this->y - 15);
         $this->y -= 10;
         /* Add table head */
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
         $page->drawText(Mage::helper('sales')->__('Products'), 35, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('SKU'), 255, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('QTY'), 430, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
         $this->y -= 15;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         /* Add body */
         foreach ($invoice->getAllItems() as $item) {
             if ($item->getOrderItem()->getParentItem()) {
                 continue;
             }
             if ($this->y < 15) {
                 $page = $this->newPage(array('table_header' => true));
             }
             /* Draw item */
             $page = $this->_drawItem($item, $page, $order);
         }
         /* Add totals */
         $page = $this->insertTotals($page, $invoice);
         if ($invoice->getStoreId()) {
             Mage::app()->getLocale()->revert();
         }
     }
     $this->_afterGetPdf();
     return $pdf;
 }
 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product             $product
  * @param Google_Service_ShoppingContent_Product $shoppingProduct
  *
  * @return Google_Service_ShoppingContent_Product
  */
 public function convertAttribute($product, $shoppingProduct)
 {
     $sp = $this->_dispatch('gshoppingv2_attribute_link', $product, $shoppingProduct);
     if ($sp !== null) {
         return $sp;
     }
     $url = $product->getProductUrl(false);
     if ($url) {
         if (!Mage::getStoreConfigFlag('web/url/use_store')) {
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         $config = Mage::getSingleton('gshoppingv2/config');
         if ($config->getAddUtmSrcGshopping($product->getStoreId())) {
             $url .= '&utm_source=GoogleShopping';
         }
         if ($customUrlParameters = $config->getCustomUrlParameters($product->getStoreId())) {
             $url .= $customUrlParameters;
         }
         $shoppingProduct->setLink($url);
     }
     return $shoppingProduct;
 }