Récemment


Error logs (null object)



  • Oups !
    {define number of products per line in other page for desktop}
    (**)



  • C'est tout bon !
    Par contre toujours les mêmes problèmes sur crossselling (avec thème modifié, parce que dans le thème natif, le crossselling change en permanence alors qu'il est identique sur le thème modifié) :

    Got error 'PHP message: PHP Notice: Undefined index: product in /var/www/clients/client3/web3/web/modules/crossselling/crossselling.php on line 253PHP message: PHP Notice: Trying to get property 'id' of non-object in /var/www/clients/client3/web3/web/modules/crossselling/crossselling.php on line 253', referer: https://www.google.com/

    public function hookProductFooter($params)
        {
            *****$cache_id = 'crossselling|productfooter|'.(int)$params['product']->id;*****
    
            if (!$this->isCached('crossselling.tpl', $this->getCacheId($cache_id))) {
                $final_products_list = $this->getOrderProducts(array($params['product']->id));
    
                if (count($final_products_list) > 0) {
                    $this->smarty->assign(
                        array(
                            'orderProducts' => $final_products_list,
                            'middlePosition_crossselling' => round(count($final_products_list) / 2, 0),
                            'crossDisplayPrice' => Configuration::get('CROSSSELLING_DISPLAY_PRICE')
                        )
                    );
                }
            }
    
            return $this->display(__FILE__, 'crossselling.tpl', $this->getCacheId($cache_id));
        }
    


  • Ben si il n'y a pas $params['product']->id il y a un gros problème^^
    Défini dans ProductController.php
    4218eb49-c42b-41f0-9f45-1eeb62bf0593-image.png



  • Et il me fait la même chose sur socialsharing (je crois que c'est les deux seules erreurs qu'il reste) :

    Got error 'PHP message: PHP Notice: Undefined index: PS_SC_GOOGLE in /var/www/clients/client3/web3/web/cache/smarty/compile/81/1f/94/811f940f06a3f697d7194319073874f8deee9fbb_0.file.socialsharing.tpl.cache.php on line 45

    <?php if ($_smarty_tpl->tpl_vars['PS_SC_GOOGLE']->value) {?>```


  • Google Plus n'existe plus donc reprend le tpl de base du module^^

    {if $PS_SC_TWITTER || $PS_SC_FACEBOOK || $PS_SC_PINTEREST}
        <p class="socialsharing_product list-inline no-print">
            {if $PS_SC_TWITTER}
                <button data-type="twitter" type="button" class="btn btn-default btn-twitter social-sharing">
                    <i class="icon-twitter"></i> {l s="Tweet" mod='socialsharing'}
                    <!-- <img src="{$link->getMediaLink("`$module_dir`img/twitter.gif")}" alt="Tweet" /> -->
                </button>
            {/if}
            {if $PS_SC_FACEBOOK}
                <button data-type="facebook" type="button" class="btn btn-default btn-facebook social-sharing">
                    <i class="icon-facebook"></i> {l s="Share" mod='socialsharing'}
                    <!-- <img src="{$link->getMediaLink("`$module_dir`img/facebook.gif")}" alt="Facebook Like" /> -->
                </button>
            {/if}
            {if $PS_SC_PINTEREST}
                <button data-type="pinterest" type="button" class="btn btn-default btn-pinterest social-sharing">
                    <i class="icon-pinterest"></i> {l s="Pinterest" mod='socialsharing'}
                    <!-- <img src="{$link->getMediaLink("`$module_dir`img/pinterest.gif")}" alt="Pinterest" /> -->
                </button>
            {/if}
        </p>
    {/if}
    


  • Ok, du coup va falloir faire le tour de tous les modules et leur tpl dans le thème.



  • Est-ce que le problème sur crossselling peut venir de ça (c'est la suite affichée) :

    PHP message: PHP Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 4 in /var/www/clients/client3/web3/web/classes/db/DbPDO.php on line 151PHP message: PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/clients/client3/web3/web/modules/crossselling/crossselling.php on line 137PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client3/web3/web/modules/crossselling/crossselling.php on line 139PHP message: PHP Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')\n AND pl.id_lang = 2\n AND cl.id_lang = 2\n ...' at line 22 in /var/www/clients/client3/web3/web/classes/db/DbPDO.php on line 151PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client3/web3/web/modules/crossselling/crossselling.php on line 183', referer: https://url/produit

    Edit : j'arrive pas à avoir cette erreur sql à chaque appel...



  • Ben là tu as une erreur dans la requête donc ça renvoie false et donc count() de false, ça ne le fait pas.
    C'est cette requête qui pète:

        $q_orders = 'SELECT o.id_order
        FROM '._DB_PREFIX_.'orders o
        LEFT JOIN '._DB_PREFIX_.'order_detail od ON (od.id_order = o.id_order)
        WHERE o.valid = 1 AND od.product_id IN ('.implode(',', $products_id).')';
        $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($q_orders);
    

    $products_id étant les id_product contenus dans le panier ou le produit de la page en cours. Donc on en revient à ton pb du hookFooter qui ne fait pas son job (à vérifier si tu n'as pas un override de ProductController.php)



  • @eolia Tiens d'ailleurs (suggestion) ne serait-il pas possible d'activer le mod debug uniquement pour les employés (vu que les clients ça risque de leur péter à la figure) et même qu'à certains employés (permissions) ? Ce serait-y pas cool ça ?
    "Comment ça c'est pas cool l'alcool ? Alors pourquoi y'a "cool" dans "alcool" ?



  • Mon override de productcontroller :
    (j'ai nettoyé, c'est pas de moi, mais y'avait tout le productcontroller là-dedans)

    <?php
    class ProductController extends ProductControllerCore
    {
        /*
        * module: alinkoverrideproductcontroller
        * date: 2023-12-02 10:00:22
        * version: 0.1
        */
            
        public function initContent()
        {
            parent::initContent();
            
            $tab = explode("<h3>", strip_tags($this->product->description, '<p><a><img><span><h3><div><li><ul><br><strong><b><iframe>')) ;
            foreach ($tab as $value)
            {
              if(strpos($value,'</h3>')>0)
                $tab_w[] = substr($value, strpos($value,'</h3>') + 5);
            }
            if(!empty($tab_w)) $this->context->smarty->assign('ONGLETS_CONTENT', $tab_w);
            preg_match_all("/<h3>(.*)<\/h3>/",$this->product->description,$out,PREG_PATTERN_ORDER);
            $this->context->smarty->assign('ONGLETS', $out[0]);
            $ONGLETS = $out[0];
        }
    }
    

    C'est pour mettre en forme d'onglets :

    Capture d’écran 2023-12-13 à 20.52.30.png

    Mais j'avoue que ton module pour les onglets me fait de l'oeil...



  • Il est bien hooké dans displayFooterProduct et displayHeader, j'ai réinitialisé le module, placé en première position sur ces 2 hooks, mais toujours pareil.



  • la requête a un argument vide :
    SELECT o.id_order
    FROM rm_orders o
    LEFT JOIN rm_order_detail od ON (od.id_order = o.id_order)
    WHERE o.valid = 1 AND od.product_id IN ()

    Notice: Undefined index: product in /var/www/clients/client1/web4/web/modules/crossselling/crossselling.php on line 253
    Notice: Trying to get property 'id' of non-object in /var/www/clients/client1/web4/web/modules/crossselling/crossselling.php on line 253
    Notice: Undefined index: product in /var/www/clients/client1/web4/web/modules/crossselling/crossselling.php on line 256
    Notice: Trying to get property 'id' of non-object in /var/www/clients/client1/web4/web/modules/crossselling/crossselling.php on line 256

    pourtant d(array($params['product']->id)) me retourne bien :
    Array
    (
    [0] => 6748
    )



  • Si je remplace :
    $cache_id = 'crossselling|productfooter|'.(int)$params['product']->id;
    par
    $cache_id = 'crossselling|productfooter|ID du produit';
    ça fonctionne, alors que d((int)$params['product']->id) me retourne bien l'ID du produit aussi...



  • 3404a216-3769-4d2b-b9e2-da9e91748f35-image.png

    A ajouter.
    Je ne sais pas pourquoi chez toi cette variable n'est pas systématiquement remplie.
    On peut aussi récupérer l'ID produit comme ça:
    $id_product = (int)Tools::getValue('id_product');



  • Le problème c'est qu'elle l'est. d((int)$params['product']->id) avant ou après $cache_id me retourne bien l'ID produit.
    Vu qu'il ne trouve pas l'index product, ne devrais-je pas faire un array_key_exists ?

    Cannot use isset() on the result of an expression (you can use "null !== expression" instead)



  • parce que tu fais un d() qui est un die et arrête le script mais s'il est appelé plusieurs fois tu ne vois pas les autres (ou alors faire un p())



  • du coup :
    if(array_key_exists('product',$params)){
    $cache_id = 'crossselling|productfooter|'.(int)$params['product']->id;
    }
    else{
    $cache_id = 'crossselling|productfooter|'.(int)Tools::getValue('id_product');
    }



  • Bon en fait, si je clique sur un produit du crossselling, même erreur (ligne 256). Donc :

    $id_product = (int)Tools::getValue('id_product');
    $cache_id = 'crossselling|productfooter|'.$id_product;

        if (!$this->isCached('crossselling.tpl', $this->getCacheId($cache_id))) {
            $final_products_list = $this->getOrderProducts(array($id_product));


  • @eolia p(((int)$params['product']->id)) donne bien l'ID puis Notice: Undefined index: product in /var/www/clients/client1/web4/web/modules/crossselling/crossselling.php on line 253

    Notice: Trying to get property 'id' of non-object in /var/www/clients/client1/web4/web/modules/crossselling/crossselling.php on line 253
    puis 0



  • donc tu mets le if(isset(... comme je t'ai dit ;)


Se connecter pour répondre