Reputation: 31
I overrided a controller file (CartController)... and I get product condition (New) And i'll be "Nouveau" at French site. I use following code, but it wasn't work. How can i fix that?
in /override/controllers/front/CartController.php:
[...]
$list_product = $cart_current->getProducts();
foreach ($list_product as $index => $product){
$product_current = new ProductCore($product['id_product'],true);
$result['label'] = $this->l($product_current->condition); /* Translation? */
}
[...]
Upvotes: 0
Views: 1440
Reputation: 1317
You can try using following after adding the translated text for 'New' in any of your modules translations
Translate::getModuleTranslation()
in place of
$this->l()
Upvotes: 0
Reputation: 174
It´s better practice override classes/Cart.php, function getProducts and add in query
, p.`condition`
Upvotes: 0
Reputation: 3349
First I'll suggest to fix your code like this:
[...]
$list_product = $cart_current->getProducts();
foreach ($list_product as $index => $product){
$product_current = new Product($product['id_product'],true); // Product not ProductCore
$result['label'] = $product_current->condition; // Translation not here in the 'controller' but we make in the 'view'
}
[...]
Then in the 'view' (cart.tpl/product.tpl):
[...]
/*
You have to comment this translations to avoid displaying. This is a workaround used also for the months.
{l s='New'} // {l s='New' mod='mymodule'} if you are in your module tpl
{l s='Used'} // Like above
*/
{l s='%s' sprintf=[$result['label']]}
[...]
Upvotes: 1