aide prestashop PhenixSuite Help
    • Catégories
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Recherche
    • S'inscrire
    • Se connecter

    À partir de (from_price) [RÉSOLU]

    Planifier Épinglé Verrouillé Déplacé Bugs & Améliorations
    11 Messages 2 Publieurs 590 Vues 2 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • Olivier75009O Hors-ligne
      Olivier75009
      dernière édition par Olivier75009

      Bonjour,
      J'ai remarqué que la classe Combination retournait $min_attribute sans faire la distinction d'un changement de prix (si toutes les valeurs price sont à 0 ou qu'elles sont les mêmes, il y a quand même un retour). Du fait, des produits déclinés ayants les mêmes prix (couleurs...) ont "à partir de" avant le prix.

      www.rituel-manucure.com

      1 réponse Dernière réponse Répondre Citer 0
      • eoliaE Hors-ligne
        eolia
        dernière édition par

        Ok,
        Pour le correctif (qui sera effectif dans la 1.6.2.21)
        Modifier la classe Product.php lignes 5410 et suivantes par:

                $row['from_price'] = false;
                if(Configuration::get('PS_ATTRIBUTE_CATEGORY_FROM') && $id_product_attribute) {
                    $info_attribute = Combination::getMinProductAttributePrice($row['id_product'], true);
                    if($info_attribute['min'] != $info_attribute['max']) {
                        $row['from_price'] = Tools::ps_round(
                            Product::getPriceStatic(
                                (int)$row['id_product'],
                                true,
                                (int)$info_attribute['id_product_attribute'],
                                6
                            ),
                            (int)Configuration::get('PS_PRICE_DISPLAY_PRECISION')
                        );
                    }
                }
        

        Et la classe Combination.php, fonction getMinProductAttributePrice() par:

            public static function getMinProductAttributePrice($id_product, $with_price = true)
            {
                $min_attribute = Db::getInstance()->getRow('
                    SELECT pa.`id_product_attribute`, pa.`price`,  MIN(pa.`price`) as `min`, MAX(pa.`price`) as `max`
                    FROM `'._DB_PREFIX_.'product_attribute` pa
                    '.Shop::addSqlAssociation('product_attribute', 'pa').'
                    WHERE pa.`id_product` = '.(int)$id_product.'
                    order by pa.`price` ASC
                ');
        
                if($min_attribute) {
                    if($with_price) {
                        return $min_attribute;
                    }
                    else {
                        return (int)$min_attribute['id_product_attribute'];
                    }
                }
        
                return 0;
            }
        

        Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

        1 réponse Dernière réponse Répondre Citer 0
        • Olivier75009O Hors-ligne
          Olivier75009
          dernière édition par Olivier75009

          Merci ! Ça fonctionne ! (enfin, l'affichage si prix différents). Par contre ça affiche le prix max, pas le min.

          www.rituel-manucure.com

          1 réponse Dernière réponse Répondre Citer 0
          • Olivier75009O Hors-ligne
            Olivier75009
            dernière édition par

            Précision : dans les déclinaisons, il se peut (ici c'est le cas) que l'incidence sur le prix soit négative (soustraction). Se peut-il que le calcul soit fait sur la valeur absolue ?

            www.rituel-manucure.com

            1 réponse Dernière réponse Répondre Citer 0
            • eoliaE Hors-ligne
              eolia
              dernière édition par

              Alors on va plutôt se baser sur une autre table.
              Essayez ceci:

                  public static function getMinProductAttributePrice($id_product, $with_price = true)
                  {
                      $min_attribute = Db::getInstance()->getRow('
                          SELECT ai.`id_attribute`, ai.`price`, 
                              MIN(ai.`price`) as `min`, MAX(ai.`price`) as `max`
                          FROM `'._DB_PREFIX_.'attribute_impact` ai
                          '.Shop::addSqlAssociation('attribute', 'ai').'
                          WHERE ai.`id_product` = '.(int)$id_product.'
                          order by ai.`price` ASC
                      ');
              
                      if($min_attribute) {
                          if($with_price) {
                              return $min_attribute;
                          }
                          else {
                              return (int)$min_attribute['id_product_attribute'];
                          }
                      }
              
                      return 0;
                  }
              

              Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

              1 réponse Dernière réponse Répondre Citer 0
              • Olivier75009O Hors-ligne
                Olivier75009
                dernière édition par Olivier75009

                J'ai le bon prix, mais je n'ai plus la mention "À partir de" (la table attribute_impact est vide)
                Capture.JPG

                www.rituel-manucure.com

                1 réponse Dernière réponse Répondre Citer 0
                • Olivier75009O Hors-ligne
                  Olivier75009
                  dernière édition par

                  les 8.40 d'impact négatif sur le prix sont bien dans la table product_attribute initialement invoquée dans la classe Combination

                  www.rituel-manucure.com

                  1 réponse Dernière réponse Répondre Citer 0
                  • eoliaE Hors-ligne
                    eolia
                    dernière édition par

                    Ok, donc c'était bien la première table qui était la bonne (Attribute_impact n'est utilisée que dans des cas particuliers)
                    MySQL ne pouvant gérer correctement la combinaison de max/min avec le order by, voici la fonction à utiliser:

                        public static function getMinProductAttributePrice($id_product, $with_price = true)
                        {
                            $attributes = Db::getInstance()->executeS('
                                SELECT pa.`id_product_attribute`, pa.`price`
                                FROM `'._DB_PREFIX_.'product_attribute` pa
                                '.Shop::addSqlAssociation('product_attribute', 'pa').'
                                WHERE pa.`id_product` = '.(int)$id_product.'
                                ORDER BY pa.`price` ASC
                            ');
                            
                            if($attributes) {
                                $min_attribute = reset($attributes);
                                $max = end($attributes);
                                if($with_price) {
                                    $min_attribute['min'] = $min_attribute['price'];
                                    $min_attribute['max'] = $max['price'];
                                    return $min_attribute;
                                }
                                else {
                                    return (int)$min_attribute['id_product_attribute'];
                                }
                            }
                    
                            return 0;
                        }
                    

                    Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

                    1 réponse Dernière réponse Répondre Citer 0
                    • Olivier75009O Hors-ligne
                      Olivier75009
                      dernière édition par

                      On y est presque, le prix est toutefois affiché TTC sur ces produits-là, alors qu'il est bien HT sur les autres (lorsqu'affiché HT pour ce groupe client).

                      www.rituel-manucure.com

                      1 réponse Dernière réponse Répondre Citer 0
                      • eoliaE Hors-ligne
                        eolia
                        dernière édition par

                                $row['from_price'] = false;
                                if(Configuration::get('PS_ATTRIBUTE_CATEGORY_FROM') && $id_product_attribute) {
                                    $info_attribute = Combination::getMinProductAttributePrice($row['id_product'], true);
                                    if($info_attribute['min'] != $info_attribute['max']) {
                                        $row['from_price'] = Tools::ps_round(
                                            Product::getPriceStatic(
                                                (int)$row['id_product'],
                                                (self::$_taxCalculationMethod == PS_TAX_EXC ? false : true),
                                                (int)$info_attribute['id_product_attribute'],
                                                6
                                            ),
                                            (int)Configuration::get('PS_PRICE_DISPLAY_PRECISION')
                                        );
                                    }
                                }
                        

                        Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

                        1 réponse Dernière réponse Répondre Citer 0
                        • Olivier75009O Hors-ligne
                          Olivier75009
                          dernière édition par

                          Merci, tout est bon

                          www.rituel-manucure.com

                          1 réponse Dernière réponse Répondre Citer 0
                          • Premier message
                            Dernier message
                          bug
                          26 sujets
                          1.6
                          24 sujets
                          front-office
                          11 sujets
                          1.5
                          8 sujets
                          1.7
                          5 sujets
                          système
                          4 sujets
                          administration
                          3 sujets
                          hack
                          3 sujets
                          module
                          3 sujets
                          performance
                          3 sujets
                          smtp
                          3 sujets
                          transporteurs
                          3 sujets
                          dashboard
                          2 sujets
                          https
                          2 sujets
                          paypal
                          2 sujets
                          promotions
                          2 sujets