Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

377
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!