Product::getProductsProperties(): 'id_image' 返回 '


Product::getProductsProperties(): 'id_image' returns 'en_default', not image

我已经构建了一个模块来制作一些产品的自定义页面。我试过

//get all products
$products_partial = Product::getProducts($this->context->language->id, 0, 1000, 'name', 'asc');
$products = Product::getProductsProperties($this->context->language->id, $products_partial);
foreach ($products as $product)
{
    //here comes some logic to select some products (not relevant for this question)
    //echo the image ID
    $results[] = $product;
}
$this->context->smarty->assign(array(
    'products' => $results
));
//this is a copy of themes/default/product-list.tpl
$this->setTemplate("product-list.tpl");

现在显示所有产品,但没有正确的图像。事实证明,$product['id_image']设置为"en_default",但我不知道为什么。但是为什么?

我试图在PrestaShop论坛上搜索问题,我找到了有相同问题的人(1,2),但没有给出解决方案。

看看一个设置en_default的函数,我认为它很清楚,为什么它这样做,它做什么。

public static function defineProductImage($row, $id_lang)
{
    if (isset($row['id_image']))
        if ($row['id_image'])
            return $row['id_product'].'-'.$row['id_image'];
    return Language::getIsoById((int)$id_lang).'-default';
}

这是从 1.5 版本开始的。