Jump to content

How to display name product, depending on the selected language?


Recommended Posts

How can I display the product name in my module depending on the selected language?public function getCustomProducts()
 

{
//$array_products_customer = Db::getInstance()->executeS('SELECT * FROM `ps_custom_product` WHERE 1');
$products = [];
$link = new Link();
//product-price
$string_products_customer = Configuration::get('CUSTOMPRODUCTS_ITEM_LIST');
$array_products_customer = explode(",", $string_products_customer);
foreach ($array_products_customer as $product) {
$products[$i] = [
json_decode(json_encode(new Product($product)), true),
json_decode(json_encode($link->getProductLink($product)), true),
$this->getUrlsProduct($product),

];

$i++;
}
return $products;
}Now I output like this in the .tpl file
{$product[0]['name'][1]}

 

Link to comment
Share on other sites

When you create the product object, you can give the language id as a parameter, so the name will no longer be an array with name in all languages.

$product_obj = new Product($id_product, false, $id_lang);

 

  • Thanks 1
Link to comment
Share on other sites

3 minutes ago, Ress said:

When you create the product object, you can give the language id as a parameter, so the name will no longer be an array with name in all languages.

$product_obj = new Product($id_product, false, $id_lang);

 

♥️

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...