IT City Posted March 26, 2022 Share Posted March 26, 2022 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 More sharing options...
IT City Posted March 26, 2022 Author Share Posted March 26, 2022 (edited) test.json var_dump($product) Edited March 26, 2022 by IT City (see edit history) Link to comment Share on other sites More sharing options...
Ress Posted March 26, 2022 Share Posted March 26, 2022 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); 1 Link to comment Share on other sites More sharing options...
IT City Posted March 26, 2022 Author Share Posted March 26, 2022 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); ♥️ 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now