Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

373
Vistas
Get image and color of an attribute in prestashop

Is there a function to get the image or the color of an Attribute in prestashop? when you add a product on the cart i would like to show the image of the chosen attribute instead of the principale image. When i read the $products variable it put the name of the attribute and other information but it doesn't show the id that i may use to find the correct image in the color folder (/img/co/)

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You need a specific function to get the image id

public static function getProducImage($id_product_attribute,$id_product)
{
  if (isset($id_product_attribute) && $id_product_attribute) {
        $id_image = Db::getInstance()->getValue('
            SELECT `image_shop`.id_image
            FROM `'._DB_PREFIX_.'product_attribute_image` pai'.
            Shop::addSqlAssociation('image', 'pai', true).'
            LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_image` = pai.`id_image`)
            WHERE id_product_attribute = '.(int)$id_product_attribute. ' ORDER by i.position ASC');
    }
    if (!isset($id_image) || !$id_image) {
        $id_image = Db::getInstance()->getValue('
            SELECT `image_shop`.id_image
            FROM `'._DB_PREFIX_.'image` i'.
            Shop::addSqlAssociation('image', 'i', true, 'image_shop.cover=1').'
            WHERE i.id_product = '.(int)$id_product
        );
    }
        return $id_image;
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda