[-] BO : Fix bug #PSCFV-10064, could not import feature in multilang, thanks @E.Bigfoot

This commit is contained in:
gRoussac
2013-10-03 16:08:53 +02:00
parent 8b2215eec5
commit 7f32e8d187
2 changed files with 26 additions and 9 deletions
+25 -8
View File
@@ -128,15 +128,32 @@ class FeatureValueCore extends ObjectModel
return $tab['value'];
}
public static function addFeatureValueImport($id_feature, $value)
public static function addFeatureValueImport($id_feature, $value, $id_product = null, $id_lang = null)
{
$id_feature_value = Db::getInstance()->getValue('
SELECT fv.`id_feature_value`
FROM '._DB_PREFIX_.'feature_value fv
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value`)
WHERE `value` = \''.pSQL($value).'\'
AND fv.`id_feature` = '.(int)$id_feature.'
GROUP BY fv.`id_feature_value`');
if (!is_null($id_product) && $id_product)
{
$id_feature_value = Db::getInstance()->getValue('
SELECT `id_feature_value`
FROM '._DB_PREFIX_.'feature_product
WHERE `id_feature` = '.(int)$id_feature.'
AND `id_product` = '.(int)$id_product);
if ($id_feature_value && !is_null($id_lang) && $id_lang)
Db::getInstance()->execute('
UPDATE '._DB_PREFIX_.'feature_value_lang
SET `value` = \''.pSQL($value).'\'
WHERE `id_feature_value` = '.(int)$id_feature_value.'
AND `id_lang` = '.(int)$id_lang);
}
else
$id_feature_value = Db::getInstance()->getValue('
SELECT fv.`id_feature_value`
FROM '._DB_PREFIX_.'feature_value fv
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value`)
WHERE `value` = \''.pSQL($value).'\'
AND fv.`id_feature` = '.(int)$id_feature.'
GROUP BY fv.`id_feature_value`');
if ($id_feature_value)
return (int)$id_feature_value;
+1 -1
View File
@@ -1543,7 +1543,7 @@ class AdminImportControllerCore extends AdminController
if(!empty($feature_name) && !empty($feature_value))
{
$id_feature = Feature::addFeatureImport($feature_name, $position);
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value);
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value, $product->id, $id_lang);
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
}
}