Jump to content

Product features suddenly missing! please help!


Recommended Posts

Hi,

 

I've imported my products (about 400) from the CSV Importer, everything was perfect, I imported categories, descriptions, prices, features, everything was there when I finish (I had to split in 11 files beacuse the timeout).

 

I checked the store yesterday and everything was there, but today I saw that several products are missing some features!!!

 

Note that I'm the only user and adm, nobody touched in the admin panel and the only thing I did from yesterday to today was change some products descriptions, only!

 

I executed some queries, please take a look:

 

 

PS: ps_feature and ps_feature_lang are ok with all the records untouched

 

 

I got one product with problem for example:

 

SELECT *

FROM `ps_feature_product`

WHERE `id_product` =347

 

 

"3","347","729"

"4","347","718"

"5","347","797"

"6","347","754"

"7","347","719"

 

Note that all features are there and also the feature values

 

 

But, now check out the ps_feature_value and ps_feature_value_lang:

 

Query:

SELECT *

FROM `ps_feature_value`

WHERE `id_feature_value` >700

LIMIT 0 , 30

 

Result:

"701","3","1"

"702","5","1"

"703","3","1"

"704","3","1"

"705","5","1"

"706","5","1"

"707","3","1"

"708","5","1"

"709","5","1"

"710","3","1"

"711","5","1"

"712","5","1"

"713","3","1"

"714","5","1"

"715","5","1"

"717","3","1"

"721","5","1"

"722","3","1"

"723","7","1"

"724","6","1"

"725","5","1"

"727","6","1"

.

.

.

 

Where are the features: 718, 719, 720, 726 ???????

 

 

Query:

 

SELECT *

FROM `ps_feature_value_lang`

WHERE `id_feature_value` >700

ORDER BY `id_feature_value`

 

"717","1","10.5% ABV"

"717","2","10.5% ABV"

"717","3","10.5% ABV"

"717","4","10.5% ABV"

"717","5","10.5% ABV"

"717","6","10.5% ABV"

"721","1","Premium American Lager"

"721","2","Premium American Lager"

"721","3","Premium American Lager"

"721","4","Premium American Lager"

"721","5","Premium American Lager"

"721","6","Premium American Lager"

"722","1","4.8% ABV"

"722","2","4.8% ABV"

"722","3","4.8% ABV"

"722","4","4.8% ABV"

"722","5","4.8% ABV"

"722","6","4.8% ABV"

"723","1","0-4 °C"

"723","2","0-4 °C"

"723","3","0-4 °C"

"723","4","0-4 °C"

"723","5","0-4 °C"

"723","6","0-4 °C"

"724","1","Pilsner"

"724","2","Pilsner"

"724","3","Pilsner"

"724","4","Pilsner"

"724","5","Pilsner"

"724","6","Pilsner"

"725","1","Altbier"

"725","2","Altbier"

"725","3","Altbier"

"725","4","Altbier"

"725","5","Altbier"

"725","6","Altbier"

"727","1","Cilíndrico"

"727","2","Cilíndrico"

"727","3","Cilíndrico"

"727","4","Cilíndrico"

"727","5","Cilíndrico"

"727","6","Cilíndrico"

.

.

.

Where are the features: 701,702,703....718, 719, 720....726??????

 

 

Please, anyone can help??

 

Thank you very much!

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

  • 1 month later...
  • 3 weeks later...

Bejamin,

 

No errors in database too.

 

Again, If I change anything using prestashop admin panel, the problem occurs.

 

I'm being forced to use SQL to update prices, quantities, etc.......it's sad...

 

Hi jfernandojr, the problem is most likely with the uploaded CSV. There is a certain way to add features in the CSV file. Please see this thread for more information and suggested solutions. http://www.prestashop.com/forums/topic/251434-solvedcsv-product-import-features-not-importing/

Link to comment
Share on other sites

Hi Benjamin,

 

Thank you very much for your attention, but, once again, there's no problem on the importing phase, my CSV is 100% according the right format.

 

Everything is ok (my 400 products are perfectly listed and working very well)... until I save something in an existent product.

 

Prestashop > Catalog > Products > nnnnn > Edit > Price > Save = Mess

 

Actual solution: Update ps_product_shop set price = xxx where id_product = yyyy.....and more...

 

I have not given up yet prestashop, because I know SQL very well, and update some info is easy, but I will have to quit this soon, because there's no way to include new products, unless you write a big sql script...too much work for my taste, it's a shame.

 

Any solution for this bug?

 

Thank you

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Hello,

I have exactly the same problem :

- Prestashop 1.5.4.1

- Features imported by CSV without problem. (in a localhost, wamp)

- Duplication of prestashop on website (OVH).

- Update product in administration.

- Some feature values dissapears.

- No database messages.

 

have you found a solution ?

 

Best regards,

Link to comment
Share on other sites

In searching in prestasop code I have found the problem :

 

When the features are imported, the method FeatureValue::addFeatureValueImport is called.

All values are imported with "custom" set to 1, but if "id_feature_value" exists the value is not duplicated.

Then some products have same feature value but the same id_feature_value too. Instead of two distinct id_feature_value.

 

When you update your product, the features values are deleted and re-created. So in the first step all products which have the same feature values have the feature value deleted.

 

I'm working on an override for the FeatureValue class.

 

For solve the problem I have made this code to execute at root of prestashop :

<?php
require_once dirname(__FILE__).'/config/config.inc.php';
require_once dirname(__FILE__).'/init.php';

$lines = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'feature_product`;');

$cache = array();
foreach($lines as $line){
    $key = $line['id_feature'].':'.$line['id_feature_value'];
    if(!isset($cache[$key])){
        $cache[$key] = $line['id_product'];
    }else{
        $o = new FeatureValue($line['id_feature_value']);
        $copy = $o->duplicateObject();
        Product::addFeatureProductImport($line['id_product'], $line['id_feature'], $copy->id);
    }
}

Best regards,

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

  • 2 weeks later...

Same problem here. I'm using PS 1.5.5.0

 

1) Import categories, products and combinations using CSV files -> After import csv, no errors, then check products randomly. OK. No problem.

 

2) Enable Multistore, add a new shop (same shop group, share Qty to sell) -> check products randomly. OK. No problem.

 

3) In new shop (multistore), edit a product (id_product=1) on price and Qty -> the second product (id_product=2), a feature's value is missing. The more products you have edit, the more other products' feature values are missing (id_product=2, 3, 4, ...)

 

Remark 1: My "Features" has 4 custom values (height, length, width, weight), and 3 pre-defined values (material, printing, packaging).

Remark 2: Two years ago, I have created a shop using PS 1.4.X. There are no such BIG BUG!
Link to comment
Share on other sites

I have confirmed that the problem occurs if you have at least one pre-defined values on "Features".

If you use all customized values, there are no problems.

 

In ROOT\classes\FeatureValue.php, addFeatureValueImport() function

 

1) Change feature_value->custom = 1;" to "$feature_value->custom = 0;" not work for me.

 

2) Regarding the revised code as per following:-

a)  $custom = 0; // the code still not work...

B)  $custom = 1; // it's work if you accept change all the pre-defined values to customized values (but SQL database file size becomes larger...)   :unsure:

public static function addFeatureValueImport($id_feature, $name, $custom) // $custom true = NOT synchronized / $custom false = synchronized
	{
		$already_exists = false;
		$id_feature_value = null;
		$custom = 1; // Set this value $custom = 0 or 1; to choose pre-defined value or customized value
		
		if (!$custom)
		{
			$rq = Db::getInstance()->executeS('
				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($name).'\'
					AND fv.`id_feature` = '.(int)$id_feature.'
				GROUP BY fv.`id_feature_value` LIMIT 1
			');

			if (isset($rq[0]['id_feature_value']) && $rq[0]['id_feature_value'] )
			{
				$id_feature_value = (int) $rq[0]['id_feature_value'];
				$already_exists = true;
			}
		}
		
		// If the feature value is custom for each product or if it is reused and doesn't already exist, we insert it
		if ($custom || !$already_exists)
		{
			$feature_value = new FeatureValue();

			$languages = Language::getLanguages();
			foreach ($languages as $language)
				$feature_value->value[$language['id_lang']] = strval($name);

			$feature_value->id_feature = (int)$id_feature;
			$feature_value->custom = $custom;
			$feature_value->add();
			
			$id_feature_value = (int) $feature_value->id;
		}
		
		return $id_feature_value;
	} 
Edited by seanloo (see edit history)
Link to comment
Share on other sites

  • 1 month later...

There was a Github fix here, https://github.com/PrestaShop/PrestaShop/commit/5d28d38a2250f497a78b4c6b7b855578aab4d7be

 

I went ahead and attached the file that has the code changes in it.

 

Please make sure to BACK UP before you touch any file via FTP How to Manually Back Up your PrestaShop Database and Files

 

 

After you confirm the backup. Use this file to test on your dev/test store. If everything works out, you can use it on your live store. the classes/FeatureValue.php file is attached. If you have 1.5 you can replace your current classes/FeatureValue.php with this file. 

FeatureValue.php

  • Like 1
Link to comment
Share on other sites

Hi, thank you for fast answer. I just found it in another topic. Sorry writting before reading 0:-] I am already trying new import. There are 2 file changed in: https://github.com/PrestaShop/PrestaShop/commit/5d28d38a2250f497a78b4c6b7b855578aab4d7be. Should I replace just this one or

 

this one too ---> controllers/admin/AdminImportController.php

 

?

 

I just installed last release 1.5.6.0 for this. Trying to move old data into now installation ...

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

  • 1 month later...
Is that seanloo solution or https://github.com/PrestaShop/PrestaShop/commit/5d28d38a2250f497a78b4c6b7b855578aab4d7be allow a product import with predefined features in the backoffice ?

 

I have 800 products in my import list, but I set my features in a backoffice... Approximately 10 and I need to import my products but I need to use predefined features for filters and search. For the moment all features in the CSV are imported as custom features and so for the country feature I have a lot of the same value.

 

Somebody can help me ?

Link to comment
Share on other sites

  • 9 months later...
×
×
  • Create New...