lervous Posted July 17, 2008 Share Posted July 17, 2008 bonsoirj'ai une erreur lorsque je vois un item...voici ce que cela ditWarning: Invalid argument supplied for foreach() in /home/ub3821/public_html/prestashop/modules/productscategory/productscategory.php on line 26comment faire pour l'arrangermerci Link to comment Share on other sites More sharing options...
FranWeb Posted July 17, 2008 Share Posted July 17, 2008 il te faut modifier la ligne 26 du fichier productscategory.phpCeci if ($products) Par ceci if ($products && count($products) > 0) Link to comment Share on other sites More sharing options...
Julien Breux Posted July 17, 2008 Share Posted July 17, 2008 Merci de rechercher sur le forum.http://www.prestashop.com/forums/viewthread/3380/ Link to comment Share on other sites More sharing options...
lervous Posted July 17, 2008 Author Share Posted July 17, 2008 bonjourje ne trouve pas la ligneest-ce cette ligne que je dois remplacer?if ($product['id_product'] == $id_current)merci Link to comment Share on other sites More sharing options...
lervous Posted July 19, 2008 Author Share Posted July 19, 2008 bonjourdois-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.<?phpclass 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now