Jump to content

erreur


lervous

Recommended Posts

bonsoir

j'ai une erreur lorsque je vois un item...voici ce que cela dit

Warning: Invalid argument supplied for foreach() in /home/ub3821/public_html/prestashop/modules/productscategory/productscategory.php on line 26

comment faire pour l'arranger

merci

Link to comment
Share on other sites

bonjour

dois-je ouvrir le fichier avec un éditeur de texte ou un autre logiciel...

comment m'assurer de toucher la ligne 26? je suis un peu confus.voici mon fichier...est-ce que pourrait me l'arranger s.v.p.

<?php

class productsCategory extends Module
{
function __construct()
{
$this->name = 'productscategory';
$this->version = '1.2';
$this->tab = 'Products';

parent::__construct();
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Products Category');
$this->description = $this->l('Display products of the same category on the product page');
}

function install()
{
if (!parent::install())
return false;
return $this->registerHook('productfooter');
}

private function getCurrentProduct($products, $id_current)
{
foreach ($products as $key => $product)
if ($product['id_product'] == $id_current)
return $key;
return 0;
}

public function hookProductFooter($params)
{
global $smarty, $cookie;

$idProduct = intval(Tools::getValue('id_product'));
$product = new Product(intval($idProduct));
$category = (intval($params['category']->id_category) == 1) ? New Category(intval($product->id_category_default)) : $params['category'];

// Get infos
$sizeOfCategoryProducts = $category->getProducts(intval($cookie->id_lang), 1, 30, NULL, NULL, true);
$categoryProducts = $category->getProducts(intval($cookie->id_lang), 1, $sizeOfCategoryProducts);

// Get positions
$middlePosition = round($sizeOfCategoryProducts / 2, 0);
$productPosition = $this->getCurrentProduct($categoryProducts, $idProduct);

// Flip middle product with current product
if ($productPosition)
{
$tmp = $categoryProducts[$middlePosition-1];
$categoryProducts[$middlePosition-1] = $categoryProducts[$productPosition];
$categoryProducts[$productPosition] = $tmp;
}

// If products tab higher than 30, slice it
if ($sizeOfCategoryProducts > 30)
{
$categoryProducts = array_slice($categoryProducts, $middlePosition - 15, 30, true);
$middlePosition = 15;
}

// Display tpl
$smarty->assign('categoryProducts', $categoryProducts);
$smarty->assign('middlePosition', $middlePosition);
return $this->display(__FILE__, 'blockcategoryproducts.tpl');
}
}
?>


merci

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...