Product::getProductsProperties(): 'id_image' 返回 'en_default',而不是图像 [英] Product::getProductsProperties(): 'id_image' returns 'en_default', not image

查看:39
本文介绍了Product::getProductsProperties(): 'id_image' 返回 'en_default',而不是图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

//获取所有产品$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){//这里有一些逻辑来选择一些产品(与这个问题无关)//回显图像ID$results[] = $product;}$this->context->smarty->assign(array('产品' =>$结果));//这是themes/default/product-list.tpl的副本$this->setTemplate("product-list.tpl");

现在显示了所有产品,但没有正确的图片.原来 $product['id_image'] 被设置为 'en_default',但我不知道为什么.但为什么?

我尝试在 PrestaShop 论坛上搜索问题,发现有同样问题的人 (1, 2),但没有给出解决方案.

解决方案

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

>

公共静态函数defineProductImage($row, $id_lang){如果 (isset($row['id_image']))如果 ($row['id_image'])返回 $row['id_product'].'-'.$row['id_image'];return Language::getIsoById((int)$id_lang).'-default';}

这是 1.5 版本.

I've build a module to make a custom page with some products. I've tried to

//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");

Now all products are shown, but without the right image. It turns out that $product['id_image'] is set to 'en_default', but I don't know why. But why?

I've tried to search for the problem on the PrestaShop forums, and I found people with the same problem (1, 2), but there was no solution given.

解决方案

Look at a function, that sets the en_default and I think it is clear, why it does, what it does.

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';
}

This is from 1.5 version.

这篇关于Product::getProductsProperties(): 'id_image' 返回 'en_default',而不是图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆