Jump to content

Recommended Posts

PrestaShop 1.5.6

I have pre-defined some feature values before import CSV.

After import the products from CSV-file, I found that many duplicate/repeat pre-defined values.

That mean all customised values become pre-defined values; while the pre-defined values are duplicated to many same values.

 

I cannot test further now regarding Feature problem. Hope PS 1.5.6 has solved the following problem too that found in PS 1.5.5.

 

PrestaShop 1.5.5

Features values missing/disappear problem.

 

http://forge.prestashop.com/browse/PSCFV-10276

 

http://www.prestashop.com/forums/topic/252700-product-features-suddenly-missing-please-help/?do=findComment&comment=1381733

 

Remark: Currently my shop still using PS 1.5.5. It is funny that all pre-defined values have to set to customised values because of the problem above (features values missing when you update product).

 

post-221841-0-89704100-1381480809_thumb.jpg

post-221841-0-65166700-1381480822_thumb.jpg

Link to comment
Share on other sites

My product Features have partial "Pre-defined values".

If edit to $feature_value->custom = 1; all features values will become "Customised values".

Then I have to manual update products one by one, to change partial Features' customised values to pre-defined values.

I have practiced this method in my shop (PS 1.5.5) previously... waste time and effort  :(

And PS 1.5.6 seem has the same problem if import products from csv-file...

Maybe it is technical limitation to import both pre-defined values and customised values in the same time...

Link to comment
Share on other sites

I have check my SQL database yesterday.

My 261 products with 7 features and 2 languages have generated more than 4100 id_feature_value.

It should be 261 * 7 * 2 = 3654 id_feature_value, right?

 

I don't know if it is normal? Maybe everytime I convert the customised values to pre-defined values, it will create a new id_feature_value, but still keep the outdated id_feature_value, right?

 

Remark: Tables "ps_feature_value" and "ps_feature_value_lang", where "id_feature_value" is auto_increment.
Link to comment
Share on other sites

  • 2 weeks later...

try out my solution for this problem.

important! all features values must exists!

 
public static function addFeatureValueImport($id_feature, $value, $id_product = null, $id_lang = null)
{
//$feature_value->getFeatureValues($id_feature);
/*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;
 
// Feature doesn't exist, create it
/*$feature_value = new FeatureValue();
$feature_value->id_feature = (int)$id_feature;
$feature_value->custom = 0;
foreach (Language::getLanguages() as $language)
$feature_value->value[$language['id_lang']] = $value;
$feature_value->add();
 
return (int)$feature_value->id; */
}
Link to comment
Share on other sites

  • 3 weeks later...

Found the issue on github, and found the fix

 

https://github.com/PrestaShop/PrestaShop/blob/d20aea056331fb484072ad94e2c4f061881aaa88/classes/FeatureValue.php

 

I just backed up the original file and replaced, works perfectly now, i think before ID were not being forced on feature attributes, but this fixes it!

Edited by RCP90 (see edit history)
Link to comment
Share on other sites

  • 1 month later...

For 1.5.6, I have another and weird solution by coincidence :)

 

Note that I didn't replace the classes>FeatureValue.php as recommended through some github pages. I am using the original one.

 

Please use this CSV format below. You'll see that all features are in one column separated by comma.

 

ID;Active;Name;Category;Price Excl. OB;Tax ID Rules;Wholesale Price;On Sale;Discount amount;Discount percent;Discount from;Discount to;Reference;Supplier reference;Supplier;Manufacturer;EAN13;UPC;Eco tax;Weight;Quantity;Short description;Description;URL rewritten;Image URL;Feature
51;1;Modern Barstool 1;Home, Barstools;31.950.000;2;;;;;;;modern_barstool;;;;;;;;15;Lorem ipsum dolor sit amet, consec tetur adipiscing.;Lorem ipsum dolor sit amet, consec tetur adipiscing.;modern_barstool;http://www.righttothedoor.com/img/p/7/0/70.jpg;Height:100cm:0,Width:50cm:0,Depth:50cm:0,Color:Brown:0,Weight:1kg:0,Size::0

Forcing product id or not doesn't matter

 

You don't need to pre-create feature values used in the CSV, if you don't, it will assign the feature value as a custom value.

 

And here is the trick:

 

When you come to the csv import view data - column assigning step, for the features column, select the column name as "Feature(Name:Value:Position)" but leave the custom name field below empty.

 

If everything is set on other columns, click on the "Import .CSV data" button.

 

You'll get the below error when you hit the import button.

Fatal error: Cannot access empty property in blablabla...\controllers\admin\AdminImportController.php on line 792

Don't worry and simply click your browser's back button and again click on the "Import .CSV data" button.

 

You're done! It is funny, huh?  :D

 

The point is that the empty feature name is not opened when we come back and it skips the empty field validation. Hopefully someone creates a bug report, coz I'm done.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
  • 2 years later...

Thanks this is what i looking for !

 

We have the same problem and it was  :angry: 

Try to change AdminFeaturesController.php (located in ../controllers/) and FeatureValue.php (located in ../classes/) with original files from PS 1.5.6.2.

This work perfect for us.  B)

Link to comment
Share on other sites

×
×
  • Create New...