translate product in car. Fix #416

This commit is contained in:
Manuel Raynaud
2014-05-30 17:07:55 +02:00
parent fe620a5a3b
commit d439197133
3 changed files with 29 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Base\CartItem as BaseCartItem;
use Thelia\Core\Event\Cart\CartEvent;
use Thelia\Model\ConfigQuery;
use Thelia\TaxEngine\Calculator;
class CartItem extends BaseCartItem
@@ -89,6 +90,23 @@ class CartItem extends BaseCartItem
return $this->getPromo() == 1 ? $this->getPromoPrice() : $this->getPrice();
}
public function getProduct(ConnectionInterface $con = null, $locale = null)
{
$product = parent::getProduct($con);
$translation = $product->getTranslation($locale);
if ($translation->isNew()) {
if (ConfigQuery::getDefaultLangWhenNoTranslationAvailable()) {
$locale = Lang::getDefaultLanguage()->getLocale();
}
}
$product->setLocale($locale);
return $product;
}
public function getRealTaxedPrice(Country $country)
{
return $this->getPromo() == 1 ? $this->getTaxedPromoPrice($country) : $this->getTaxedPrice($country);