[*] Classes : improve performances of "Feature detachable" feature

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8754 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
aFolletete
2011-09-24 15:03:21 +00:00
parent cfca41b012
commit 78f6a4e20a
18 changed files with 334 additions and 149 deletions
+26 -12
View File
@@ -80,20 +80,41 @@ class ProductDownloadCore extends ObjectModel
protected $table = 'product_download';
protected $identifier = 'id_product_download';
protected static $feature_active = null;
/**
* Build a virtual product
*
* @param integer $id_product_download Existing productDownload id in order to load object (optional)
*/
public function __construct($id_product_download = NULL)
public function __construct($id_product_download = null)
{
parent::__construct($id_product_download);
// @TODO check if the file is present on hard drive
}
public function delete($deleteFile=false)
public function add($autodate = true, $nullValues = false)
{
if (parent::add($autodate, $nullValues))
{
// Set cache of feature detachable to true
if ($this->active)
Configuration::updateGlobalValue('PS_VIRTUAL_PROD_FEATURE_ACTIVE', '1');
return true;
}
return false;
}
public function update($nullValues = false)
{
if (parent::update($nullValues))
{
// Refresh cache of feature detachable because the row can be deactive
Configuration::updateGlobalValue('PS_VIRTUAL_PROD_FEATURE_ACTIVE', self::isCurrentlyUsed($this->table, true));
return true;
}
return false;
}
public function delete($deleteFile = false)
{
if ($deleteFile)
return $this->deleteFile();
@@ -118,7 +139,6 @@ class ProductDownloadCore extends ObjectModel
return $fields;
}
/**
* Delete the file
*
@@ -280,14 +300,8 @@ class ProductDownloadCore extends ObjectModel
*/
public static function isFeatureActive()
{
if (self::$feature_active === null)
self::$feature_active = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_product_download`
FROM `'._DB_PREFIX_.'product_download`
');
return self::$feature_active;
return Configuration::get('PS_VIRTUAL_PROD_FEATURE_ACTIVE');
}
}