Skip to content

Commit

Permalink
Add new methods to check if category flat is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-carter committed May 8, 2017
1 parent 9bbac94 commit c9eb855
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app/code/community/Creare/CreareSeoSitemap/Block/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
protected $store;
protected $sitemapHelper;
protected $xmlSitemaps = false;
protected $_flatEnabled = array();

public function __construct(array $args)
{
Expand All @@ -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
*/
Expand Down

0 comments on commit c9eb855

Please sign in to comment.