translate product in car. Fix #416
This commit is contained in:
@@ -82,9 +82,9 @@ class Cart extends BaseLoop implements ArraySearchLoopInterface
|
|||||||
public function parseResults(LoopResult $loopResult)
|
public function parseResults(LoopResult $loopResult)
|
||||||
{
|
{
|
||||||
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
|
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
|
||||||
|
$locale = $this->request->getSession()->getLang()->getLocale();
|
||||||
foreach ($loopResult->getResultDataCollection() as $cartItem) {
|
foreach ($loopResult->getResultDataCollection() as $cartItem) {
|
||||||
$product = $cartItem->getProduct();
|
$product = $cartItem->getProduct(null, $locale);
|
||||||
$productSaleElement = $cartItem->getProductSaleElements();
|
$productSaleElement = $cartItem->getProductSaleElements();
|
||||||
|
|
||||||
$loopResultRow = new LoopResultRow();
|
$loopResultRow = new LoopResultRow();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use Thelia\Core\Event\TheliaEvents;
|
|||||||
use Thelia\Model\Base\CartItem as BaseCartItem;
|
use Thelia\Model\Base\CartItem as BaseCartItem;
|
||||||
|
|
||||||
use Thelia\Core\Event\Cart\CartEvent;
|
use Thelia\Core\Event\Cart\CartEvent;
|
||||||
|
use Thelia\Model\ConfigQuery;
|
||||||
use Thelia\TaxEngine\Calculator;
|
use Thelia\TaxEngine\Calculator;
|
||||||
|
|
||||||
class CartItem extends BaseCartItem
|
class CartItem extends BaseCartItem
|
||||||
@@ -89,6 +90,23 @@ class CartItem extends BaseCartItem
|
|||||||
return $this->getPromo() == 1 ? $this->getPromoPrice() : $this->getPrice();
|
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)
|
public function getRealTaxedPrice(Country $country)
|
||||||
{
|
{
|
||||||
return $this->getPromo() == 1 ? $this->getTaxedPromoPrice($country) : $this->getTaxedPrice($country);
|
return $this->getPromo() == 1 ? $this->getTaxedPromoPrice($country) : $this->getTaxedPrice($country);
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ use Thelia\Model\Map\LangTableMap;
|
|||||||
class Lang extends BaseLang
|
class Lang extends BaseLang
|
||||||
{
|
{
|
||||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||||
|
|
||||||
|
protected static $defaultLanguage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the default language object, using a local variable to cache it.
|
* Return the default language object, using a local variable to cache it.
|
||||||
*
|
*
|
||||||
@@ -24,10 +27,13 @@ class Lang extends BaseLang
|
|||||||
*/
|
*/
|
||||||
public static function getDefaultLanguage()
|
public static function getDefaultLanguage()
|
||||||
{
|
{
|
||||||
$default_lang = LangQuery::create()->findOneByByDefault(1);
|
if (null === self::$defaultLanguage) {
|
||||||
|
self::$defaultLanguage = LangQuery::create()->findOneByByDefault(1);
|
||||||
|
|
||||||
if ($default_lang == null) throw new \RuntimeException("No default language is defined. Please define one.");
|
if (self::$defaultLanguage == null) throw new \RuntimeException("No default language is defined. Please define one.");
|
||||||
return $default_lang;
|
}
|
||||||
|
|
||||||
|
return self::$defaultLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toggleDefault()
|
public function toggleDefault()
|
||||||
|
|||||||
Reference in New Issue
Block a user