Merge branch 'master' of https://github.com/thelia/thelia
This commit is contained in:
@@ -34,6 +34,7 @@ use Thelia\Core\Template\Loop\Argument\Argument;
|
|||||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||||
use Thelia\Model\CountryQuery;
|
use Thelia\Model\CountryQuery;
|
||||||
use Thelia\Model\CurrencyQuery;
|
use Thelia\Model\CurrencyQuery;
|
||||||
|
use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||||
use Thelia\Type\TypeCollection;
|
use Thelia\Type\TypeCollection;
|
||||||
use Thelia\Type;
|
use Thelia\Type;
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ use Thelia\Type;
|
|||||||
*
|
*
|
||||||
* Product Sale Elements loop
|
* Product Sale Elements loop
|
||||||
*
|
*
|
||||||
* @todo : manage currency and attribute_availability
|
* @todo : manage attribute_availability ?
|
||||||
*
|
*
|
||||||
* Class ProductSaleElements
|
* Class ProductSaleElements
|
||||||
* @package Thelia\Core\Template\Loop
|
* @package Thelia\Core\Template\Loop
|
||||||
@@ -68,9 +69,9 @@ class ProductSaleElements extends BaseLoop
|
|||||||
new Argument(
|
new Argument(
|
||||||
'order',
|
'order',
|
||||||
new TypeCollection(
|
new TypeCollection(
|
||||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'attribute', 'attribute_reverse'))
|
new Type\EnumListType(array('min_price', 'max_price', 'promo', 'new', 'random'))
|
||||||
),
|
),
|
||||||
'attribute'
|
'random'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -94,16 +95,16 @@ class ProductSaleElements extends BaseLoop
|
|||||||
foreach ($orders as $order) {
|
foreach ($orders as $order) {
|
||||||
switch ($order) {
|
switch ($order) {
|
||||||
case "min_price":
|
case "min_price":
|
||||||
$search->addAscendingOrderByColumn('real_lowest_price', Criteria::ASC);
|
$search->addAscendingOrderByColumn('price_FINAL_PRICE', Criteria::ASC);
|
||||||
break;
|
break;
|
||||||
case "max_price":
|
case "max_price":
|
||||||
$search->addDescendingOrderByColumn('real_lowest_price');
|
$search->addDescendingOrderByColumn('price_FINAL_PRICE');
|
||||||
break;
|
break;
|
||||||
case "promo":
|
case "promo":
|
||||||
$search->addDescendingOrderByColumn('main_product_is_promo');
|
$search->orderByPromo(Criteria::DESC);
|
||||||
break;
|
break;
|
||||||
case "new":
|
case "new":
|
||||||
$search->addDescendingOrderByColumn('main_product_is_new');
|
$search->orderByNewness(Criteria::DESC);
|
||||||
break;
|
break;
|
||||||
case "random":
|
case "random":
|
||||||
$search->clearOrderByColumns();
|
$search->clearOrderByColumns();
|
||||||
@@ -125,12 +126,22 @@ class ProductSaleElements extends BaseLoop
|
|||||||
$defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1);
|
$defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1);
|
||||||
$defaultCurrencySuffix = '_default_currency';
|
$defaultCurrencySuffix = '_default_currency';
|
||||||
|
|
||||||
$search->joinProductPrice('price', Criteria::INNER_JOIN);
|
$search->joinProductPrice('price', Criteria::LEFT_JOIN)
|
||||||
//->addJoinCondition('price', '');
|
->addJoinCondition('price', '`price`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
|
||||||
|
|
||||||
$search->withColumn('`price`.CURRENCY_ID', 'price_CURRENCY_ID')
|
$search->joinProductPrice('price' . $defaultCurrencySuffix, Criteria::LEFT_JOIN)
|
||||||
->withColumn('`price`.PRICE', 'price_PRICE')
|
->addJoinCondition('price_default_currency', '`price' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
|
||||||
->withColumn('`price`.PROMO_PRICE', 'price_PROMO_PRICE');
|
|
||||||
|
/**
|
||||||
|
* rate value is checked as a float in overloaded getRate method.
|
||||||
|
*/
|
||||||
|
$priceSelectorAsSQL = 'ROUND(CASE WHEN ISNULL(`price`.PRICE) THEN `price_default_currency`.PRICE * ' . $currency->getRate() . ' ELSE `price`.PRICE END, 2)';
|
||||||
|
$promoPriceSelectorAsSQL = 'ROUND(CASE WHEN ISNULL(`price`.PRICE) THEN `price_default_currency`.PROMO_PRICE * ' . $currency->getRate() . ' ELSE `price`.PROMO_PRICE END, 2)';
|
||||||
|
$search->withColumn($priceSelectorAsSQL, 'price_PRICE')
|
||||||
|
->withColumn($promoPriceSelectorAsSQL, 'price_PROMO_PRICE')
|
||||||
|
->withColumn('CASE WHEN ' . ProductSaleElementsTableMap::PROMO . ' = 1 THEN ' . $promoPriceSelectorAsSQL . ' ELSE ' . $priceSelectorAsSQL . ' END', 'price_FINAL_PRICE');
|
||||||
|
|
||||||
|
$search->groupById();
|
||||||
|
|
||||||
$PSEValues = $this->search($search, $pagination);
|
$PSEValues = $this->search($search, $pagination);
|
||||||
|
|
||||||
@@ -153,8 +164,6 @@ class ProductSaleElements extends BaseLoop
|
|||||||
->set("IS_PROMO", $PSEValue->getPromo() === 1 ? 1 : 0)
|
->set("IS_PROMO", $PSEValue->getPromo() === 1 ? 1 : 0)
|
||||||
->set("IS_NEW", $PSEValue->getNewness() === 1 ? 1 : 0)
|
->set("IS_NEW", $PSEValue->getNewness() === 1 ? 1 : 0)
|
||||||
->set("WEIGHT", $PSEValue->getWeight())
|
->set("WEIGHT", $PSEValue->getWeight())
|
||||||
|
|
||||||
->set("CURRENCY", $PSEValue->getVirtualColumn('price_CURRENCY_ID'))
|
|
||||||
->set("PRICE", $price)
|
->set("PRICE", $price)
|
||||||
->set("PRICE_TAX", $taxedPrice - $price)
|
->set("PRICE_TAX", $taxedPrice - $price)
|
||||||
->set("TAXED_PRICE", $taxedPrice)
|
->set("TAXED_PRICE", $taxedPrice)
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Thelia extends Kernel
|
|||||||
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
|
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
|
||||||
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
|
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
|
||||||
if ($this->isDebug()) {
|
if ($this->isDebug()) {
|
||||||
|
//$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
|
||||||
$con->useDebug(true);
|
$con->useDebug(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
{*include file="includes/header.html"*}
|
||||||
|
|
||||||
Here you are : {navigate to="current"}<br />
|
Here you are : {navigate to="current"}<br />
|
||||||
From : {navigate to="return_to"}<br />
|
From : {navigate to="return_to"}<br />
|
||||||
Index : {navigate to="index"}<br />
|
Index : {navigate to="index"}<br />
|
||||||
@@ -60,7 +62,7 @@ Index : {navigate to="index"}<br />
|
|||||||
<h4>Product sale elements</h4>
|
<h4>Product sale elements</h4>
|
||||||
|
|
||||||
{assign var=current_product value=$ID}
|
{assign var=current_product value=$ID}
|
||||||
{loop name="pse" type="product_sale_elements" product="$ID"}
|
{loop name="pse" type="product_sale_elements" product="$ID" order="promo,min_price"}
|
||||||
<div style="border: solid 2px darkorange; padding: 5px; margin: 5px;">
|
<div style="border: solid 2px darkorange; padding: 5px; margin: 5px;">
|
||||||
{loop name="combi" type="attribute_combination" product_sale_elements="$ID"}
|
{loop name="combi" type="attribute_combination" product_sale_elements="$ID"}
|
||||||
{$ATTRIBUTE_TITLE} = {$ATTRIBUTE_AVAILABILITY_TITLE}<br />
|
{$ATTRIBUTE_TITLE} = {$ATTRIBUTE_AVAILABILITY_TITLE}<br />
|
||||||
@@ -88,3 +90,5 @@ Index : {navigate to="index"}<br />
|
|||||||
{elseloop rel="product"}
|
{elseloop rel="product"}
|
||||||
<h2>Produit introuvable !</h2>
|
<h2>Produit introuvable !</h2>
|
||||||
{/elseloop}
|
{/elseloop}
|
||||||
|
|
||||||
|
{*include file="includes/footer.html"*}
|
||||||
Reference in New Issue
Block a user