Jump to content

Solved ! Specials block doesn't work


Recommended Posts

The picture of specials block didn't show, I tried to fix it by reload all the blockspecials dokuments from original Presta package. After reinstallation of specials block, the front page disappeared, showing totally white. If I uninstall specials block, the front page turnes back to normal. But I need to have specials block. Kan anyone please tell me what's wrong with this block? What should I do to solve the problem? Many thanks! Salomonsson

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

Hi Vekia!

 

Thank you so much for your help. Here's the error message:

 

Fatal error: Call to undefined method Product::getRandomSpecial() in /home2/i-smycken.sajtpro.se/www/prestashop/modules/blockspecials/blockspecials.php on line 89

 

Best regards

Salomonsson

Link to comment
Share on other sites

okay, so can you please check the classes/Product.php file

 

is there this function:

public static function getRandomSpecial($id_lang, $beginning = false, $ending = false, Context $context = null)
{
 if (!$context)
  $context = Context::getContext();
 $front = true;
 if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
  $front = false;
 $current_date = date('Y-m-d H:i:s');
 $product_reductions = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context, true);
 if ($product_reductions)
 {
  $ids_product = ' AND (';
  foreach ($product_reductions as $product_reduction)
   $ids_product .= '( product_shop.`id_product` = '.(int)$product_reduction['id_product'].($product_reduction['id_product_attribute'] ? ' AND product_attribute_shop.`id_product_attribute`='.(int)$product_reduction['id_product_attribute'] :'').') OR';
  $ids_product = rtrim($ids_product, 'OR').')';
  $groups = FrontController::getCurrentCustomerGroups();
  $sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
  // Please keep 2 distinct queries because RAND() is an awful way to achieve this result
  $sql = 'SELECT product_shop.id_product, MAX(product_attribute_shop.id_product_attribute) id_product_attribute
 FROM `'._DB_PREFIX_.'product` p
 '.Shop::addSqlAssociation('product', 'p').'
 LEFT JOIN  `'._DB_PREFIX_.'product_attribute` pa ON (product_shop.id_product = pa.id_product)
 '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1').'
 WHERE product_shop.`active` = 1
  '.(($ids_product) ? $ids_product : '').'
  AND p.`id_product` IN (
   SELECT cp.`id_product`
   FROM `'._DB_PREFIX_.'category_group` cg
   LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
   WHERE cg.`id_group` '.$sql_groups.'
  )
 '.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').'
 GROUP BY product_shop.id_product
 ORDER BY RAND()';
  $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
  if (!$id_product = $result['id_product'])
   return false;
  $sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`,
  pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
  p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`,
  DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
  INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).'
   DAY)) > 0 AS new
 FROM `'._DB_PREFIX_.'product` p
 LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
  p.`id_product` = pl.`id_product`
  AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
 )
 '.Shop::addSqlAssociation('product', 'p').'
 LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
 Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
 LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
 '.Product::sqlStock('p', 0).'
 WHERE p.id_product = '.(int)$id_product.'
 GROUP BY product_shop.id_product';
  $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
  if (!$row)
   return false;
  if ($result['id_product_attribute'])
   $row['id_product_attribute'] = $result['id_product_attribute'];
  return Product::getProductProperties($id_lang, $row);
 }
 else
  return false;
}

 

?

 

if not, i attached the file once agin (just replace the file that you've got there now) - don't forget about backup!

http://pastebin.com/yFBXgh4k

 

 

 

ps - maybe you use some module that override this class?

Link to comment
Share on other sites

×
×
  • Create New...