From c9eb8550136faeadbfb886328f7cbc1eac33647f Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 8 May 2017 11:51:00 +0100 Subject: [PATCH] Add new methods to check if category flat is enabled --- .../Creare/CreareSeoSitemap/Block/Sitemap.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/app/code/community/Creare/CreareSeoSitemap/Block/Sitemap.php b/app/code/community/Creare/CreareSeoSitemap/Block/Sitemap.php index a6c6e6b..d914589 100644 --- a/app/code/community/Creare/CreareSeoSitemap/Block/Sitemap.php +++ b/app/code/community/Creare/CreareSeoSitemap/Block/Sitemap.php @@ -6,6 +6,7 @@ protected $store; protected $sitemapHelper; protected $xmlSitemaps = false; + protected $_flatEnabled = array(); public function __construct(array $args) { @@ -20,6 +21,36 @@ public function __construct(array $args) parent::__construct($args); } + /** + * Retrieve Catalog Product Flat Helper object + * + * @return Mage_Catalog_Helper_Product_Flat + */ + public function getFlatHelper() + { + return Mage::helper('catalog/category_flat'); + } + + /** + * Retrieve is flat enabled flag + * Return always false if magento run admin + * + * @return bool + */ + public function isEnabledFlat() + { + // Flat Data can be used only on frontend + if (Mage::app()->getStore()->isAdmin()) { + return false; + } + $storeId = $this->getStoreId(); + if (!isset($this->_flatEnabled[$storeId])) { + $flatHelper = $this->getFlatHelper(); + $this->_flatEnabled[$storeId] = $flatHelper->isAvailable() && $flatHelper->isBuilt($storeId); + } + return $this->_flatEnabled[$storeId]; + } + /** * @return Creare_CreareSeoSitemap_Helper_Data */