Monday 12 March 2012

Product.php => array_key_exists() expects parameter 2


A simple warning in Product.php

PHP Warning: array_key_exists() expects parameter 2 to be array, boolean given in /home/prestashop/classes/Product.php on line 1804


Please replace this code in the line no: 1866

$attribute_price = Tools::convertPrice((is_array($result) && array_key_exists('attribute_price', $result)) ? (float)($result['attribute_price']) : 0, $id_currency);


6 comments:

  1. Warning: array_key_exists() expects parameter 2 to be array, boolean given in /home/showroom8888/public_html/classes/Product.php on line 1854

    Auriez vous une idée, svp
    merci

    ReplyDelete
    Replies
    1. je ne vois pas ce que vous voulez dire, pouvez vous me détailler svp ?
      Vérifier le deuxième paramètre de la fonction : array_key_exists(). Si c’est un “ array” ou pas ( using is_array() )

      Delete
  2. j'ai aussi cette erreur Unable to save result set in /home/showroom8888/public_html/classes/MySQL.php on line 76
    Cordialement

    ReplyDelete
  3. Thx you!

    Martin Opatrný

    ReplyDelete
  4. I like the article on the topic due to this reason it is seen that other readers are showing their interest by commenting on it.
    Prestashop developer

    ReplyDelete
  5. Hello!

    After importing some tables from another database I have this prestashop error:

    Warning: array_key_exists (): The first argument should be either a string or an integer in /htdocs/public/www/tienda/modules/blocklayered/blocklayered.php on line 2835

    That line is as follows:

    if (array_key_exists ($ filter_link_rewrite, $ option_checked_array))

    and this is the expanded fraction in which this line is inserted:

    foreach ($ filter_blocks as & $ type_filter)
    {
    $ filter_name = (! empty ($ type_filter ['url_name'])? $ type_filter ['url_name']: $ type_filter ['name']);
    $ filter_link_rewrite = Tools :: link_rewrite ($ filter_name);

    if (count ($ type_filter)> 0 &&! isset ($ type_filter ['slider']))
    {
    foreach ($ type_filter ['values'] as $ key => $ values)
    {
    $ nofollow = false;
    if (! empty ($ values ​​['checked']) && in_array ($ type_filter ['type'], $ blacklist))
    $ global_nofollow = true;

    $ option_checked_clone_array = $ option_checked_array;

    // If not filters checked, add parameter
    $ value_name =! empty ($ values ​​['url_name'])? $ values ​​['url_name']: $ values ​​['name'];

    if (! in_array (Tools :: link_rewrite ($ value_name), $ param_group_selected_array [$ filter_link_rewrite]))
    {
    // Update parameter filter checked before
    if (array_key_exists ($ filter_link_rewrite, $ option_checked_array))
    {
    $ option_checked_clone_array [$ filter_link_rewrite] = $ option_checked_clone_array [$ filter_link_rewrite] $ this-> getAnchor (). str_replace ($ this-> getAnchor (), '_', Tools :: link_rewrite ($ value_name));

    if (in_array ($ type_filter ['type'], $ blacklist))
    $ nofollow = true;
    }
    else
    $ option_checked_clone_array [$ filter_link_rewrite] = $ this-> getAnchor (). str_replace ($ this-> getAnchor (), '', Tools :: link_rewrite ($ value_name));
    }
    else
    {
    // Remove selected parameters
    $ option_checked_clone_array [$ filter_link_rewrite] = str_replace ($ this-> getAnchor (). str_replace ($ this-> getAnchor (), '', Tools :: link_rewrite ($ value_name)), '', $ option_checked_clone_array [$ filter_link_rewrite] );
    if (empty ($ option_checked_clone_array [$ filter_link_rewrite]))
    unset ($ option_checked_clone_array [$ filter_link_rewrite]);
    }
    $ parameters = '';
    ksort ($ option_checked_clone_array); // Order parameters
    foreach ($ option_checked_clone_array as $ key_group => $ value_group)
    $ parameters. = '/'. str_replace ($ this-> getAnchor (), '_', $ key_group) $ value_group;

    I have no idea what it means or what to modify ... I spend my life trying, searching for google, or asking for help in blogs, .. and that way I solve problems and learn something :)

    My shop with the error: https://vivirahora.es/tienda/es/3-alimentacion
    (the filter also does not display the category name, only the number of matches)

    Thanks in advance and please be patient that I am new to this!

    Ana

    ReplyDelete