Prestashop SQL 查询仅显示活动语言的类别名称

Prestashop SQL Query to display category names of just the active language

我有一个几年前开发的 Prestashop 模块。该模块根据所选类别显示新产品。我最近发现,如果我为商店设置了不止一种语言(例如 en、fr),并且我会用英语和法语编辑类别名称。该模块将在前端显示两个名称,而不是仅根据活动的商店语言显示一个。

我认为编辑后的下面代码 blocknewproduct.php 获取类别列表:

    public function hookdisplayHome($params)
{
    $list_id_category= Tools::jsonDecode(Configuration::get('PS_NB_NEW_PRODUCT_CATEGORY'));
    $resuilt_category=array(); 
    if($list_id_category)
    {
        $sql="select distinct id_category,name from "._DB_PREFIX_."category_lang where id_category in (".implode(',',$list_id_category).")";
        $categories=Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
    }
    if (!$this->isCached('blocknewproducts_home.tpl', $this->getCacheId('blocknewproducts-home')))
        BlockNewProducts1::$cache_new_products = $this->getNewProducts();
    {
        $this->smarty->assign(array(
            'new_products' => BlockNewProducts1::$cache_new_products,
            'categories' =>$categories,
            'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
            'homeSize' => Image::getSize(ImageType::getFormatedName('home'))
        ));
    }

    if (BlockNewProducts1::$cache_new_products === false)
        return false;
    $this->pagination(count($this->getAllNewProducts($this->context->language->id))); // by ats_edited

    return $this->display(__FILE__, 'blocknewproducts_home.tpl', $this->getCacheId('blocknewproducts-home'));
}

任何人都可以建议需要编辑此代码的哪一行以仅获取要显示的活动语言的类别名称。

在blocknewproducts_home.tpl文件中,下面这段代码用于显示列表。

<ul class="list-category-new-product plists">
                    <li class="plist {if !isset($id_category_select) || !$id_category_select}active{/if}"><a href="#" data-id="0" title="{l s='All' mod='blocknewproducts1'}">{l s='All' mod='blocknewproducts1'}</a></li>
                    {foreach from=$categories item='category'}
                        <li class="plist {if $category.id_category==$id_category_select}active{/if}"><a href="#" data-id="{$category.id_category}" title="{$category.name}">{$category.name}</a></li>
                    {/foreach}
                </ul>

抱歉,我不是程序员,只是网页设计师,所以我需要明确的帮助。

将 $sql 更改为:

$sql="select distinct id_category,name from "._DB_PREFIX_."category_lang where id_category in (".implode(',',$list_id_category).") and id_lang = ".(int) $this->context->language->id;