Jump to content

problem with datasheet (prestashop 1.5 1.0


Recommended Posts

  • 4 months later...

Hi guys,

 

I am also suffering with the same problem now on 1.5.1. When I deactivate the "new product block" module everything is fine again.

But I don't want to deactivate this module because I like it. Is there a way to change the code of the "new product block" in order to solve this problem??

 

Hope you have a solution for this...

Link to comment
Share on other sites

OK thanks Aldi M but I can't figure out what I should change in the code.

Vincent AUGAGNEUR says "you can modify the file /classes/Product.php line 3169"

 

at line 3169 of product.php I have this:

 

WHERE `id_product` IN ('.implode($product_implode, ',').')

 

What have to be changed in this code?

 

Thanks for your quick reply!

Link to comment
Share on other sites

@BnB: Hmmm... not sure but I'm guessing it's due to the different version you're using. I used v.1.5.2. Try search for 'function cacheFrontFeatures' in your editor. It should be in the 3rd line from the bottom within that function that you should change from this:

 

self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang][] = $row;

 

...to this:

 

if (!isset(self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang][$row['id_product']]))
self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang][$row['id_product']] = $row;

 

Take note, though, that I haven't tried this myself as I already hacked my theme to fix this issue before I found this solution.

Link to comment
Share on other sites

You have to change the function code (cacheFrontFeatures) in the / classes / product.php line 3162 or 3169.

 

And replace it with the following code:

public static function cacheFrontFeatures($product_ids, $id_lang)
{
 if (!Feature::isFeatureActive())
  return;
 $product_implode = array();
 foreach ($product_ids as $id_product)
  if ((int)$id_product && !array_key_exists($id_product.'-'.$id_lang, self::$_cacheFeatures))
   $product_implode[] = (int)$id_product;
 if (!count($product_implode))
  return;
 $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
 SELECT id_product, name, value, pf.id_feature
 FROM '._DB_PREFIX_.'feature_product pf
 LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = '.(int)$id_lang.')
 LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$id_lang.')
 LEFT JOIN '._DB_PREFIX_.'feature f ON (f.id_feature = pf.id_feature)
 WHERE `id_product` IN ('.implode($product_implode, ',').')
 ORDER BY f.position ASC');
 foreach ($result as $row)
 {
  if (!array_key_exists($row['id_product'].'-'.$id_lang, self::$_frontFeaturesCache))
   self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang] = array();
  if (!isset(self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang][$row['id_feature']]))
   self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang][$row['id_feature']] = $row;
 }
}

 

This code is the same function but taken from the 1.5.3 version of prestashop.

I hope this helps.

Link to comment
Share on other sites

×
×
  • Create New...