Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

369
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda