// import OK for product feature

This commit is contained in:
vChabot
2011-09-26 13:50:53 +00:00
parent a2fe45d687
commit 9333fd1034
2 changed files with 20 additions and 11 deletions
+6 -2
View File
@@ -33,7 +33,7 @@ class FeatureCore extends ObjectModel
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 128);
protected $fieldsValidateLang = array('name' => 'isGenericName');
protected $fieldsValidateLang = array('name' => 'isGenericName', 'position' => 'isInt');
protected $table = 'feature';
protected $identifier = 'id_feature';
@@ -183,7 +183,7 @@ class FeatureCore extends ObjectModel
* @param integer $id_product Product id
* @param array $value Feature Value
*/
public static function addFeatureImport($name)
public static function addFeatureImport($name, $position = false)
{
$rq = Db::getInstance()->getRow('SELECT `id_feature` FROM '._DB_PREFIX_.'feature_lang WHERE `name` = \''.pSQL($name).'\' GROUP BY `id_feature`');
if (!empty($rq))
@@ -193,6 +193,10 @@ class FeatureCore extends ObjectModel
$languages = Language::getLanguages();
foreach ($languages as $language)
$feature->name[$language['id_lang']] = strval($name);
if ($position)
$feature->position = (int)$position;
else
$feature->position = self::getHigherPosition() + 1;
$feature->add();
return $feature->id;
}