Php Prestashop SQL查询,仅显示活动语言的类别名称
我在几年前开发了一个Prestashop模块。该模块根据所选类别显示新产品。我最近发现,如果我为商店设置了多种语言(例如en、fr),并且我用英语和法语编辑了类别名称。该模块将在前端显示两个名称,而不是仅显示一个基于活动车间语言的名称 我认为编辑的blocknewproduct.php中的以下代码将获取类别列表:Php Prestashop SQL查询,仅显示活动语言的类别名称,php,sql,smarty,prestashop-1.6,Php,Sql,Smarty,Prestashop 1.6,我在几年前开发了一个Prestashop模块。该模块根据所选类别显示新产品。我最近发现,如果我为商店设置了多种语言(例如en、fr),并且我用英语和法语编辑了类别名称。该模块将在前端显示两个名称,而不是仅显示一个基于活动车间语言的名称 我认为编辑的blocknewproduct.php中的以下代码将获取类别列表: public function hookdisplayHome($params) { $list_id_category= Tools::jsonDecode(Conf
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>
{foreach from=$categories item='category'}
{/foreach}
很抱歉,我不是程序员,只是网页设计师,因此我需要明确的帮助。将$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;
将$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;