Merge branch 'master' of github.com:thelia/thelia
This commit is contained in:
@@ -35,6 +35,7 @@ use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Model\Map\FeatureProductTableMap;
|
||||
use Thelia\Model\Map\ProductPriceTableMap;
|
||||
use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
@@ -54,8 +55,6 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* Class Product
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
* @todo : manage currency in price filter
|
||||
*/
|
||||
class Product extends BaseI18nLoop
|
||||
{
|
||||
@@ -137,6 +136,10 @@ class Product extends BaseI18nLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$currency = $this->request->getSession()->getCurrency();
|
||||
$defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1);
|
||||
$defaultCurrencySuffix = '_default_currency';
|
||||
|
||||
$search = ProductQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
@@ -144,7 +147,7 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$attributeNonStrictMatch = $this->getAttribute_non_strict_match();
|
||||
$isPSELeftJoinList = array();
|
||||
$isProductPriceLeftJoinList = array();
|
||||
$isProductPriceFirstLeftJoin = array();
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -232,46 +235,6 @@ class Product extends BaseI18nLoop
|
||||
->where('NOT ISNULL(`is_max_weight`.ID)');
|
||||
}
|
||||
|
||||
$min_price = $this->getMin_price();
|
||||
|
||||
if(null !== $min_price) {
|
||||
$isPSELeftJoinList[] = 'is_min_price';
|
||||
$isProductPriceLeftJoinList['is_min_price'] = 'min_price_data';
|
||||
$minPriceJoin = new Join();
|
||||
$minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data');
|
||||
$minPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->joinProductSaleElements('is_min_price', Criteria::LEFT_JOIN)
|
||||
->addJoinObject($minPriceJoin)
|
||||
->condition('in_promo', '`is_min_price`.promo'. Criteria::EQUAL .'1')
|
||||
->condition('not_in_promo', '`is_min_price`.promo'. Criteria::NOT_EQUAL .'1')
|
||||
->condition('min_promo_price', '`min_price_data`.promo_price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR)
|
||||
->condition('min_price', '`min_price_data`.price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR)
|
||||
->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_min_price')
|
||||
->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price')
|
||||
->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
$max_price = $this->getMax_price();
|
||||
|
||||
if(null !== $max_price) {
|
||||
$isPSELeftJoinList[] = 'is_max_price';
|
||||
$isProductPriceLeftJoinList['is_max_price'] = 'max_price_data';
|
||||
$minPriceJoin = new Join();
|
||||
$minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data');
|
||||
$minPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->joinProductSaleElements('is_max_price', Criteria::LEFT_JOIN)
|
||||
->addJoinObject($minPriceJoin)
|
||||
->condition('in_promo', '`is_max_price`.promo'. Criteria::EQUAL .'1')
|
||||
->condition('not_in_promo', '`is_max_price`.promo'. Criteria::NOT_EQUAL .'1')
|
||||
->condition('min_promo_price', '`max_price_data`.promo_price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR)
|
||||
->condition('max_price', '`max_price_data`.price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR)
|
||||
->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_max_price')
|
||||
->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price')
|
||||
->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
if( $attributeNonStrictMatch != '*' ) {
|
||||
if($attributeNonStrictMatch == 'none') {
|
||||
$actuallyUsedAttributeNonStrictMatchList = $isPSELeftJoinList;
|
||||
@@ -286,13 +249,96 @@ class Product extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
$min_price = $this->getMin_price();
|
||||
|
||||
if(null !== $min_price) {
|
||||
|
||||
if(false === ConfigQuery::useTaxFreeAmounts()) {
|
||||
// @todo
|
||||
}
|
||||
|
||||
$isPSELeftJoinList[] = 'is_min_price';
|
||||
$isProductPriceFirstLeftJoin = array('is_min_price', 'min_price_data');
|
||||
|
||||
$minPriceJoin = new Join();
|
||||
$minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data');
|
||||
$minPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->joinProductSaleElements('is_min_price', Criteria::LEFT_JOIN)
|
||||
->addJoinObject($minPriceJoin, 'is_min_price_join')
|
||||
->addJoinCondition('is_min_price_join', '`min_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
if($defaultCurrency->getId() != $currency->getId()) {
|
||||
$minPriceJoinDefaultCurrency = new Join();
|
||||
$minPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data' . $defaultCurrencySuffix);
|
||||
$minPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->addJoinObject($minPriceJoinDefaultCurrency, 'is_min_price_join' . $defaultCurrencySuffix)
|
||||
->addJoinCondition('is_min_price_join' . $defaultCurrencySuffix, '`min_price_data' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
/**
|
||||
* In propel we trust : $currency->getRate() always returns a float.
|
||||
* Or maybe not : rate value is checked as a float in overloaded getRate method.
|
||||
*/
|
||||
$MinPriceToCompareAsSQL = 'CASE WHEN ISNULL(CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data`.PROMO_PRICE ELSE `min_price_data`.PRICE END) THEN
|
||||
CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data' . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `min_price_data' . $defaultCurrencySuffix . '`.PRICE END * ' . $currency->getRate() . '
|
||||
ELSE
|
||||
CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data`.PROMO_PRICE ELSE `min_price_data`.PRICE END
|
||||
END';
|
||||
} else {
|
||||
$MinPriceToCompareAsSQL = 'CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data`.PROMO_PRICE ELSE `min_price_data`.PRICE END';
|
||||
}
|
||||
|
||||
$search->where('ROUND(' . $MinPriceToCompareAsSQL . ', 2)>=?', $min_price, \PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
$max_price = $this->getMax_price();
|
||||
|
||||
if(null !== $max_price) {
|
||||
$isPSELeftJoinList[] = 'is_max_price';
|
||||
$isProductPriceFirstLeftJoin = array('is_max_price', 'max_price_data');
|
||||
|
||||
$maxPriceJoin = new Join();
|
||||
$maxPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data');
|
||||
$maxPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->joinProductSaleElements('is_max_price', Criteria::LEFT_JOIN)
|
||||
->addJoinObject($maxPriceJoin, 'is_max_price_join')
|
||||
->addJoinCondition('is_max_price_join', '`max_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
if($defaultCurrency->getId() != $currency->getId()) {
|
||||
$maxPriceJoinDefaultCurrency = new Join();
|
||||
$maxPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data' . $defaultCurrencySuffix);
|
||||
$maxPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->addJoinObject($maxPriceJoinDefaultCurrency, 'is_max_price_join' . $defaultCurrencySuffix)
|
||||
->addJoinCondition('is_max_price_join' . $defaultCurrencySuffix, '`max_price_data' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
/**
|
||||
* In propel we trust : $currency->getRate() always returns a float.
|
||||
* Or maybe not : rate value is checked as a float in overloaded getRate method.
|
||||
*/
|
||||
$MaxPriceToCompareAsSQL = 'CASE WHEN ISNULL(CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data`.PROMO_PRICE ELSE `max_price_data`.PRICE END) THEN
|
||||
CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data' . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `max_price_data' . $defaultCurrencySuffix . '`.PRICE END * ' . $currency->getRate() . '
|
||||
ELSE
|
||||
CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data`.PROMO_PRICE ELSE `max_price_data`.PRICE END
|
||||
END';
|
||||
|
||||
} else {
|
||||
$MaxPriceToCompareAsSQL = 'CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data`.PROMO_PRICE ELSE `max_price_data`.PRICE END';
|
||||
}
|
||||
|
||||
$search->where('ROUND(' . $MaxPriceToCompareAsSQL . ', 2)<=?', $max_price, \PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
/*
|
||||
* for ordering and outputs, the product will be :
|
||||
* - new if at least one the criteria matching PSE is new
|
||||
* - in promo if at least one the criteria matching PSE is in promo
|
||||
*/
|
||||
|
||||
if(count($isProductPriceLeftJoinList) == 0) {
|
||||
/* if we don't have any join yet, let's make a global one */
|
||||
if(empty($isProductPriceFirstLeftJoin)) {
|
||||
if(count($isPSELeftJoinList) == 0) {
|
||||
$joiningTable = "global";
|
||||
$isPSELeftJoinList[] = $joiningTable;
|
||||
@@ -301,13 +347,22 @@ class Product extends BaseI18nLoop
|
||||
$joiningTable = $isPSELeftJoinList[0];
|
||||
}
|
||||
|
||||
$isProductPriceLeftJoinList[$joiningTable] = 'global_price_data';
|
||||
$isProductPriceFirstLeftJoin = array($joiningTable, 'global_price_data');
|
||||
|
||||
$minPriceJoin = new Join();
|
||||
$minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data');
|
||||
$minPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
$globalPriceJoin = new Join();
|
||||
$globalPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data');
|
||||
$globalPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->addJoinObject($minPriceJoin);
|
||||
$search->addJoinObject($globalPriceJoin, 'global_price_join')
|
||||
->addJoinCondition('global_price_join', '`global_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
if($defaultCurrency->getId() != $currency->getId()) {
|
||||
$globalPriceJoinDefaultCurrency = new Join();
|
||||
$globalPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data' . $defaultCurrencySuffix);
|
||||
$globalPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN);
|
||||
$search->addJoinObject($globalPriceJoinDefaultCurrency, 'global_price_join' . $defaultCurrencySuffix)
|
||||
->addJoinCondition('global_price_join' . $defaultCurrencySuffix, '`global_price_data' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -330,15 +385,24 @@ class Product extends BaseI18nLoop
|
||||
$booleanMatchedPromoList[] = '`' . $isPSELeftJoin . '`.PROMO';
|
||||
$booleanMatchedNewnessList[] = '`' . $isPSELeftJoin . '`.NEWNESS';
|
||||
}
|
||||
$booleanMatchedPriceList = array();
|
||||
foreach($isProductPriceLeftJoinList as $pSE => $isProductPriceLeftJoin) {
|
||||
$booleanMatchedPriceList[] = 'CASE WHEN `' . $pSE . '`.PROMO=1 THEN `' . $isProductPriceLeftJoin . '`.PROMO_PRICE ELSE `' . $isProductPriceLeftJoin . '`.PRICE END';
|
||||
}
|
||||
$search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedPromoList) . '), 2)', 'main_product_is_promo');
|
||||
$search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedNewnessList) . '), 2)', 'main_product_is_new');
|
||||
$search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedPriceList) . '), 2)', 'real_highest_price');
|
||||
$search->withColumn('ROUND(MIN(' . implode(' OR ', $booleanMatchedPriceList) . '), 2)', 'real_lowest_price');
|
||||
|
||||
$booleanMatchedPrice = 'CASE WHEN `' . $isProductPriceFirstLeftJoin[0] . '`.PROMO=1 THEN `' . $isProductPriceFirstLeftJoin[1] . '`.PROMO_PRICE ELSE `' . $isProductPriceFirstLeftJoin[1] . '`.PRICE END';
|
||||
$booleanMatchedPriceDefaultCurrency = 'CASE WHEN `' . $isProductPriceFirstLeftJoin[0] . '`.PROMO=1 THEN `' . $isProductPriceFirstLeftJoin[1] . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `' . $isProductPriceFirstLeftJoin[1] . $defaultCurrencySuffix . '`.PRICE END';
|
||||
|
||||
if($defaultCurrency->getId() != $currency->getId()) {
|
||||
/**
|
||||
* In propel we trust : $currency->getRate() always returns a float.
|
||||
* Or maybe not : rate value is checked as a float in overloaded getRate method.
|
||||
*/
|
||||
$priceToCompareAsSQL = 'CASE WHEN ISNULL(' . $booleanMatchedPrice .') THEN ' . $booleanMatchedPriceDefaultCurrency . ' * ' . $currency->getRate() . ' ELSE ' . $booleanMatchedPrice . ' END';
|
||||
} else {
|
||||
$priceToCompareAsSQL = $booleanMatchedPrice;
|
||||
}
|
||||
|
||||
$search->withColumn('ROUND(MAX(' . $priceToCompareAsSQL . '), 2)', 'real_highest_price');
|
||||
$search->withColumn('ROUND(MIN(' . $priceToCompareAsSQL . '), 2)', 'real_lowest_price');
|
||||
|
||||
$current = $this->getCurrent();
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -94,22 +95,37 @@ class ProductSaleElements extends BaseLoop
|
||||
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
//$search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE);
|
||||
case "min_price":
|
||||
$search->addAscendingOrderByColumn('real_lowest_price', Criteria::ASC);
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
//$search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE);
|
||||
case "max_price":
|
||||
$search->addDescendingOrderByColumn('real_lowest_price');
|
||||
break;
|
||||
case "attribute":
|
||||
//$search->orderByPosition(Criteria::ASC);
|
||||
case "promo":
|
||||
$search->addDescendingOrderByColumn('main_product_is_promo');
|
||||
break;
|
||||
case "attribute_reverse":
|
||||
//$search->orderByPosition(Criteria::DESC);
|
||||
case "new":
|
||||
$search->addDescendingOrderByColumn('main_product_is_new');
|
||||
break;
|
||||
case "random":
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
break(2);
|
||||
}
|
||||
}
|
||||
|
||||
$currency = $this->getCurrency();
|
||||
$currencyId = $this->getCurrency();
|
||||
if(null !== $currency) {
|
||||
$currency = CurrencyQuery::create()->findOneById($currencyId);
|
||||
if(null === $currency) {
|
||||
throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop');
|
||||
}
|
||||
} else {
|
||||
$currency = $this->request->getSession()->getCurrency();
|
||||
}
|
||||
|
||||
$defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1);
|
||||
$defaultCurrencySuffix = '_default_currency';
|
||||
|
||||
$search->joinProductPrice('price', Criteria::INNER_JOIN);
|
||||
//->addJoinCondition('price', '');
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Thelia\Core;
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionWrapper;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
@@ -81,9 +82,10 @@ class Thelia extends Kernel
|
||||
$manager = new ConnectionManagerSingle();
|
||||
$manager->setConfiguration($definePropel->getConfig());
|
||||
$serviceContainer->setConnectionManager('thelia', $manager);
|
||||
|
||||
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
|
||||
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
|
||||
if ($this->isDebug()) {
|
||||
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
|
||||
|
||||
$con->useDebug(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2276,7 +2276,10 @@ abstract class Currency implements ActiveRecordInterface
|
||||
$productPricesToDelete = $this->getProductPrices(new Criteria(), $con)->diff($productPrices);
|
||||
|
||||
|
||||
$this->productPricesScheduledForDeletion = $productPricesToDelete;
|
||||
//since at least one column in the foreign key is at the same time a PK
|
||||
//we can not just set a PK to NULL in the lines below. We have to store
|
||||
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
|
||||
$this->productPricesScheduledForDeletion = clone $productPricesToDelete;
|
||||
|
||||
foreach ($productPricesToDelete as $productPriceRemoved) {
|
||||
$productPriceRemoved->setCurrency(null);
|
||||
|
||||
@@ -58,12 +58,6 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
*/
|
||||
protected $virtualColumns = array();
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The value for the product_sale_elements_id field.
|
||||
* @var int
|
||||
@@ -372,17 +366,6 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
return array_keys(get_object_vars($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [product_sale_elements_id] column value.
|
||||
*
|
||||
@@ -467,27 +450,6 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return \Thelia\Model\ProductPrice The current object (for fluent API support)
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = ProductPriceTableMap::ID;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [product_sale_elements_id] column.
|
||||
*
|
||||
@@ -659,28 +621,25 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
try {
|
||||
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductPriceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductPriceTableMap::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductPriceTableMap::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->product_sale_elements_id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductPriceTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductPriceTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->currency_id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductPriceTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductPriceTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->price = (null !== $col) ? (double) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductPriceTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductPriceTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->promo_price = (null !== $col) ? (double) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductPriceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductPriceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductPriceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductPriceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -693,7 +652,7 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 7; // 7 = ProductPriceTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 6; // 6 = ProductPriceTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\ProductPrice object", 0, $e);
|
||||
@@ -934,15 +893,8 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$modifiedColumns = array();
|
||||
$index = 0;
|
||||
|
||||
$this->modifiedColumns[] = ProductPriceTableMap::ID;
|
||||
if (null !== $this->id) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductPriceTableMap::ID . ')');
|
||||
}
|
||||
|
||||
// check the columns in natural order for more readable SQL queries
|
||||
if ($this->isColumnModified(ProductPriceTableMap::ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'ID';
|
||||
}
|
||||
if ($this->isColumnModified(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_ID';
|
||||
}
|
||||
@@ -972,9 +924,6 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$stmt = $con->prepare($sql);
|
||||
foreach ($modifiedColumns as $identifier => $columnName) {
|
||||
switch ($columnName) {
|
||||
case 'ID':
|
||||
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'PRODUCT_SALE_ELEMENTS_ID':
|
||||
$stmt->bindValue($identifier, $this->product_sale_elements_id, PDO::PARAM_INT);
|
||||
break;
|
||||
@@ -1001,13 +950,6 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
|
||||
try {
|
||||
$pk = $con->lastInsertId();
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException('Unable to get autoincrement id.', 0, $e);
|
||||
}
|
||||
$this->setId($pk);
|
||||
|
||||
$this->setNew(false);
|
||||
}
|
||||
|
||||
@@ -1056,24 +998,21 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
{
|
||||
switch ($pos) {
|
||||
case 0:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getProductSaleElementsId();
|
||||
break;
|
||||
case 2:
|
||||
case 1:
|
||||
return $this->getCurrencyId();
|
||||
break;
|
||||
case 3:
|
||||
case 2:
|
||||
return $this->getPrice();
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
return $this->getPromoPrice();
|
||||
break;
|
||||
case 5:
|
||||
case 4:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 6:
|
||||
case 5:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -1099,19 +1038,18 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
*/
|
||||
public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
|
||||
{
|
||||
if (isset($alreadyDumpedObjects['ProductPrice'][$this->getPrimaryKey()])) {
|
||||
if (isset($alreadyDumpedObjects['ProductPrice'][serialize($this->getPrimaryKey())])) {
|
||||
return '*RECURSION*';
|
||||
}
|
||||
$alreadyDumpedObjects['ProductPrice'][$this->getPrimaryKey()] = true;
|
||||
$alreadyDumpedObjects['ProductPrice'][serialize($this->getPrimaryKey())] = true;
|
||||
$keys = ProductPriceTableMap::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getProductSaleElementsId(),
|
||||
$keys[2] => $this->getCurrencyId(),
|
||||
$keys[3] => $this->getPrice(),
|
||||
$keys[4] => $this->getPromoPrice(),
|
||||
$keys[5] => $this->getCreatedAt(),
|
||||
$keys[6] => $this->getUpdatedAt(),
|
||||
$keys[0] => $this->getProductSaleElementsId(),
|
||||
$keys[1] => $this->getCurrencyId(),
|
||||
$keys[2] => $this->getPrice(),
|
||||
$keys[3] => $this->getPromoPrice(),
|
||||
$keys[4] => $this->getCreatedAt(),
|
||||
$keys[5] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1161,24 +1099,21 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
{
|
||||
switch ($pos) {
|
||||
case 0:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setProductSaleElementsId($value);
|
||||
break;
|
||||
case 2:
|
||||
case 1:
|
||||
$this->setCurrencyId($value);
|
||||
break;
|
||||
case 3:
|
||||
case 2:
|
||||
$this->setPrice($value);
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
$this->setPromoPrice($value);
|
||||
break;
|
||||
case 5:
|
||||
case 4:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 6:
|
||||
case 5:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1205,13 +1140,12 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
{
|
||||
$keys = ProductPriceTableMap::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setProductSaleElementsId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setCurrencyId($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setPromoPrice($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[0], $arr)) $this->setProductSaleElementsId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setCurrencyId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setPrice($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setPromoPrice($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1223,7 +1157,6 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
{
|
||||
$criteria = new Criteria(ProductPriceTableMap::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(ProductPriceTableMap::ID)) $criteria->add(ProductPriceTableMap::ID, $this->id);
|
||||
if ($this->isColumnModified(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID)) $criteria->add(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id);
|
||||
if ($this->isColumnModified(ProductPriceTableMap::CURRENCY_ID)) $criteria->add(ProductPriceTableMap::CURRENCY_ID, $this->currency_id);
|
||||
if ($this->isColumnModified(ProductPriceTableMap::PRICE)) $criteria->add(ProductPriceTableMap::PRICE, $this->price);
|
||||
@@ -1245,29 +1178,36 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ProductPriceTableMap::DATABASE_NAME);
|
||||
$criteria->add(ProductPriceTableMap::ID, $this->id);
|
||||
$criteria->add(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id);
|
||||
$criteria->add(ProductPriceTableMap::CURRENCY_ID, $this->currency_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
* Returns the composite primary key for this object.
|
||||
* The array elements will be in same order as specified in XML.
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
$pks = array();
|
||||
$pks[0] = $this->getProductSaleElementsId();
|
||||
$pks[1] = $this->getCurrencyId();
|
||||
|
||||
return $pks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
* Set the [composite] primary key.
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @param array $keys The elements of the composite key (order must match the order in XML file).
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
public function setPrimaryKey($keys)
|
||||
{
|
||||
$this->setId($key);
|
||||
$this->setProductSaleElementsId($keys[0]);
|
||||
$this->setCurrencyId($keys[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1277,7 +1217,7 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
public function isPrimaryKeyNull()
|
||||
{
|
||||
|
||||
return null === $this->getId();
|
||||
return (null === $this->getProductSaleElementsId()) && (null === $this->getCurrencyId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1301,7 +1241,6 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
if ($makeNew) {
|
||||
$copyObj->setNew(true);
|
||||
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1434,7 +1373,6 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->product_sale_elements_id = null;
|
||||
$this->currency_id = null;
|
||||
$this->price = null;
|
||||
|
||||
@@ -21,7 +21,6 @@ use Thelia\Model\Map\ProductPriceTableMap;
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildProductPriceQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildProductPriceQuery orderByProductSaleElementsId($order = Criteria::ASC) Order by the product_sale_elements_id column
|
||||
* @method ChildProductPriceQuery orderByCurrencyId($order = Criteria::ASC) Order by the currency_id column
|
||||
* @method ChildProductPriceQuery orderByPrice($order = Criteria::ASC) Order by the price column
|
||||
@@ -29,7 +28,6 @@ use Thelia\Model\Map\ProductPriceTableMap;
|
||||
* @method ChildProductPriceQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildProductPriceQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
* @method ChildProductPriceQuery groupById() Group by the id column
|
||||
* @method ChildProductPriceQuery groupByProductSaleElementsId() Group by the product_sale_elements_id column
|
||||
* @method ChildProductPriceQuery groupByCurrencyId() Group by the currency_id column
|
||||
* @method ChildProductPriceQuery groupByPrice() Group by the price column
|
||||
@@ -52,7 +50,6 @@ use Thelia\Model\Map\ProductPriceTableMap;
|
||||
* @method ChildProductPrice findOne(ConnectionInterface $con = null) Return the first ChildProductPrice matching the query
|
||||
* @method ChildProductPrice findOneOrCreate(ConnectionInterface $con = null) Return the first ChildProductPrice matching the query, or a new ChildProductPrice object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildProductPrice findOneById(int $id) Return the first ChildProductPrice filtered by the id column
|
||||
* @method ChildProductPrice findOneByProductSaleElementsId(int $product_sale_elements_id) Return the first ChildProductPrice filtered by the product_sale_elements_id column
|
||||
* @method ChildProductPrice findOneByCurrencyId(int $currency_id) Return the first ChildProductPrice filtered by the currency_id column
|
||||
* @method ChildProductPrice findOneByPrice(double $price) Return the first ChildProductPrice filtered by the price column
|
||||
@@ -60,7 +57,6 @@ use Thelia\Model\Map\ProductPriceTableMap;
|
||||
* @method ChildProductPrice findOneByCreatedAt(string $created_at) Return the first ChildProductPrice filtered by the created_at column
|
||||
* @method ChildProductPrice findOneByUpdatedAt(string $updated_at) Return the first ChildProductPrice filtered by the updated_at column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildProductPrice objects filtered by the id column
|
||||
* @method array findByProductSaleElementsId(int $product_sale_elements_id) Return ChildProductPrice objects filtered by the product_sale_elements_id column
|
||||
* @method array findByCurrencyId(int $currency_id) Return ChildProductPrice objects filtered by the currency_id column
|
||||
* @method array findByPrice(double $price) Return ChildProductPrice objects filtered by the price column
|
||||
@@ -114,10 +110,10 @@ abstract class ProductPriceQuery extends ModelCriteria
|
||||
* Go fast if the query is untouched.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(12, $con);
|
||||
* $obj = $c->findPk(array(12, 34), $con);
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param array[$product_sale_elements_id, $currency_id] $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildProductPrice|array|mixed the result, formatted by the current formatter
|
||||
@@ -127,7 +123,7 @@ abstract class ProductPriceQuery extends ModelCriteria
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = ProductPriceTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
|
||||
if ((null !== ($obj = ProductPriceTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
@@ -155,10 +151,11 @@ abstract class ProductPriceQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, PRODUCT_SALE_ELEMENTS_ID, CURRENCY_ID, PRICE, PROMO_PRICE, CREATED_AT, UPDATED_AT FROM product_price WHERE ID = :p0';
|
||||
$sql = 'SELECT PRODUCT_SALE_ELEMENTS_ID, CURRENCY_ID, PRICE, PROMO_PRICE, CREATED_AT, UPDATED_AT FROM product_price WHERE PRODUCT_SALE_ELEMENTS_ID = :p0 AND CURRENCY_ID = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
@@ -168,7 +165,7 @@ abstract class ProductPriceQuery extends ModelCriteria
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildProductPrice();
|
||||
$obj->hydrate($row);
|
||||
ProductPriceTableMap::addInstanceToPool($obj, (string) $key);
|
||||
ProductPriceTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
@@ -197,7 +194,7 @@ abstract class ProductPriceQuery extends ModelCriteria
|
||||
/**
|
||||
* Find objects by primary key
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(12, 56, 832), $con);
|
||||
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
|
||||
* </code>
|
||||
* @param array $keys Primary keys to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
@@ -227,8 +224,10 @@ abstract class ProductPriceQuery extends ModelCriteria
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
$this->addUsingAlias(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $key[0], Criteria::EQUAL);
|
||||
$this->addUsingAlias(ProductPriceTableMap::CURRENCY_ID, $key[1], Criteria::EQUAL);
|
||||
|
||||
return $this->addUsingAlias(ProductPriceTableMap::ID, $key, Criteria::EQUAL);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,49 +239,17 @@ abstract class ProductPriceQuery extends ModelCriteria
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(ProductPriceTableMap::ID, $keys, Criteria::IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterById(1234); // WHERE id = 1234
|
||||
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
|
||||
* $query->filterById(array('min' => 12)); // WHERE id > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $id The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildProductPriceQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterById($id = null, $comparison = null)
|
||||
{
|
||||
if (is_array($id)) {
|
||||
$useMinMax = false;
|
||||
if (isset($id['min'])) {
|
||||
$this->addUsingAlias(ProductPriceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($id['max'])) {
|
||||
$this->addUsingAlias(ProductPriceTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
if (empty($keys)) {
|
||||
return $this->add(null, '1<>1', Criteria::CUSTOM);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
$cton0 = $this->getNewCriterion(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $key[0], Criteria::EQUAL);
|
||||
$cton1 = $this->getNewCriterion(ProductPriceTableMap::CURRENCY_ID, $key[1], Criteria::EQUAL);
|
||||
$cton0->addAnd($cton1);
|
||||
$this->addOr($cton0);
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(ProductPriceTableMap::ID, $id, $comparison);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -699,7 +666,9 @@ abstract class ProductPriceQuery extends ModelCriteria
|
||||
public function prune($productPrice = null)
|
||||
{
|
||||
if ($productPrice) {
|
||||
$this->addUsingAlias(ProductPriceTableMap::ID, $productPrice->getId(), Criteria::NOT_EQUAL);
|
||||
$this->addCond('pruneCond0', $this->getAliasedColName(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID), $productPrice->getProductSaleElementsId(), Criteria::NOT_EQUAL);
|
||||
$this->addCond('pruneCond1', $this->getAliasedColName(ProductPriceTableMap::CURRENCY_ID), $productPrice->getCurrencyId(), Criteria::NOT_EQUAL);
|
||||
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -2248,7 +2248,10 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
$productPricesToDelete = $this->getProductPrices(new Criteria(), $con)->diff($productPrices);
|
||||
|
||||
|
||||
$this->productPricesScheduledForDeletion = $productPricesToDelete;
|
||||
//since at least one column in the foreign key is at the same time a PK
|
||||
//we can not just set a PK to NULL in the lines below. We have to store
|
||||
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
|
||||
$this->productPricesScheduledForDeletion = clone $productPricesToDelete;
|
||||
|
||||
foreach ($productPricesToDelete as $productPriceRemoved) {
|
||||
$productPriceRemoved->setProductSaleElements(null);
|
||||
|
||||
@@ -42,4 +42,9 @@ class ConfigQuery extends BaseConfigQuery {
|
||||
{
|
||||
return self::read('active-template', 'default');
|
||||
}
|
||||
|
||||
public static function useTaxFreeAmounts()
|
||||
{
|
||||
return self::read('use_tax_free_amounts', 'default') == 1;
|
||||
}
|
||||
} // ConfigQuery
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\Base\Currency as BaseCurrency;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
@@ -80,4 +81,19 @@ class Currency extends BaseCurrency {
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETECURRENCY, new CurrencyEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [rate] column value.
|
||||
*
|
||||
* @return double
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getRate()
|
||||
{
|
||||
if(false === filter_var($this->rate, FILTER_VALIDATE_FLOAT)) {
|
||||
throw new PropelException('Currency::rate is not float value');
|
||||
}
|
||||
|
||||
return $this->rate;
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class ProductPriceTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 7;
|
||||
const NUM_COLUMNS = 6;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,12 +67,7 @@ class ProductPriceTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 7;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
*/
|
||||
const ID = 'product_price.ID';
|
||||
const NUM_HYDRATE_COLUMNS = 6;
|
||||
|
||||
/**
|
||||
* the column name for the PRODUCT_SALE_ELEMENTS_ID field
|
||||
@@ -116,12 +111,12 @@ class ProductPriceTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'ProductSaleElementsId', 'CurrencyId', 'Price', 'PromoPrice', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'productSaleElementsId', 'currencyId', 'price', 'promoPrice', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(ProductPriceTableMap::ID, ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, ProductPriceTableMap::CURRENCY_ID, ProductPriceTableMap::PRICE, ProductPriceTableMap::PROMO_PRICE, ProductPriceTableMap::CREATED_AT, ProductPriceTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_SALE_ELEMENTS_ID', 'CURRENCY_ID', 'PRICE', 'PROMO_PRICE', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'product_sale_elements_id', 'currency_id', 'price', 'promo_price', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
self::TYPE_PHPNAME => array('ProductSaleElementsId', 'CurrencyId', 'Price', 'PromoPrice', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('productSaleElementsId', 'currencyId', 'price', 'promoPrice', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, ProductPriceTableMap::CURRENCY_ID, ProductPriceTableMap::PRICE, ProductPriceTableMap::PROMO_PRICE, ProductPriceTableMap::CREATED_AT, ProductPriceTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('PRODUCT_SALE_ELEMENTS_ID', 'CURRENCY_ID', 'PRICE', 'PROMO_PRICE', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('product_sale_elements_id', 'currency_id', 'price', 'promo_price', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -131,12 +126,12 @@ class ProductPriceTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'ProductSaleElementsId' => 1, 'CurrencyId' => 2, 'Price' => 3, 'PromoPrice' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productSaleElementsId' => 1, 'currencyId' => 2, 'price' => 3, 'promoPrice' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
|
||||
self::TYPE_COLNAME => array(ProductPriceTableMap::ID => 0, ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID => 1, ProductPriceTableMap::CURRENCY_ID => 2, ProductPriceTableMap::PRICE => 3, ProductPriceTableMap::PROMO_PRICE => 4, ProductPriceTableMap::CREATED_AT => 5, ProductPriceTableMap::UPDATED_AT => 6, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_SALE_ELEMENTS_ID' => 1, 'CURRENCY_ID' => 2, 'PRICE' => 3, 'PROMO_PRICE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'product_sale_elements_id' => 1, 'currency_id' => 2, 'price' => 3, 'promo_price' => 4, 'created_at' => 5, 'updated_at' => 6, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
self::TYPE_PHPNAME => array('ProductSaleElementsId' => 0, 'CurrencyId' => 1, 'Price' => 2, 'PromoPrice' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('productSaleElementsId' => 0, 'currencyId' => 1, 'price' => 2, 'promoPrice' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
|
||||
self::TYPE_COLNAME => array(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID => 0, ProductPriceTableMap::CURRENCY_ID => 1, ProductPriceTableMap::PRICE => 2, ProductPriceTableMap::PROMO_PRICE => 3, ProductPriceTableMap::CREATED_AT => 4, ProductPriceTableMap::UPDATED_AT => 5, ),
|
||||
self::TYPE_RAW_COLNAME => array('PRODUCT_SALE_ELEMENTS_ID' => 0, 'CURRENCY_ID' => 1, 'PRICE' => 2, 'PROMO_PRICE' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
|
||||
self::TYPE_FIELDNAME => array('product_sale_elements_id' => 0, 'currency_id' => 1, 'price' => 2, 'promo_price' => 3, 'created_at' => 4, 'updated_at' => 5, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -153,11 +148,10 @@ class ProductPriceTableMap extends TableMap
|
||||
$this->setPhpName('ProductPrice');
|
||||
$this->setClassName('\\Thelia\\Model\\ProductPrice');
|
||||
$this->setPackage('Thelia.Model');
|
||||
$this->setUseIdGenerator(true);
|
||||
$this->setUseIdGenerator(false);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER', 'product_sale_elements', 'ID', true, null, null);
|
||||
$this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', true, null, null);
|
||||
$this->addForeignPrimaryKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER' , 'product_sale_elements', 'ID', true, null, null);
|
||||
$this->addForeignPrimaryKey('CURRENCY_ID', 'CurrencyId', 'INTEGER' , 'currency', 'ID', true, null, null);
|
||||
$this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
|
||||
$this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
@@ -186,6 +180,59 @@ class ProductPriceTableMap extends TableMap
|
||||
);
|
||||
} // getBehaviors()
|
||||
|
||||
/**
|
||||
* Adds an object to the instance pool.
|
||||
*
|
||||
* Propel keeps cached copies of objects in an instance pool when they are retrieved
|
||||
* from the database. In some cases you may need to explicitly add objects
|
||||
* to the cache in order to ensure that the same objects are always returned by find*()
|
||||
* and findPk*() calls.
|
||||
*
|
||||
* @param \Thelia\Model\ProductPrice $obj A \Thelia\Model\ProductPrice object.
|
||||
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
|
||||
*/
|
||||
public static function addInstanceToPool($obj, $key = null)
|
||||
{
|
||||
if (Propel::isInstancePoolingEnabled()) {
|
||||
if (null === $key) {
|
||||
$key = serialize(array((string) $obj->getProductSaleElementsId(), (string) $obj->getCurrencyId()));
|
||||
} // if key === null
|
||||
self::$instances[$key] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an object from the instance pool.
|
||||
*
|
||||
* Propel keeps cached copies of objects in an instance pool when they are retrieved
|
||||
* from the database. In some cases -- especially when you override doDelete
|
||||
* methods in your stub classes -- you may need to explicitly remove objects
|
||||
* from the cache in order to prevent returning objects that no longer exist.
|
||||
*
|
||||
* @param mixed $value A \Thelia\Model\ProductPrice object or a primary key value.
|
||||
*/
|
||||
public static function removeInstanceFromPool($value)
|
||||
{
|
||||
if (Propel::isInstancePoolingEnabled() && null !== $value) {
|
||||
if (is_object($value) && $value instanceof \Thelia\Model\ProductPrice) {
|
||||
$key = serialize(array((string) $value->getProductSaleElementsId(), (string) $value->getCurrencyId()));
|
||||
|
||||
} elseif (is_array($value) && count($value) === 2) {
|
||||
// assume we've been passed a primary key";
|
||||
$key = serialize(array((string) $value[0], (string) $value[1]));
|
||||
} elseif ($value instanceof Criteria) {
|
||||
self::$instances = [];
|
||||
|
||||
return;
|
||||
} else {
|
||||
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProductPrice object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
|
||||
throw $e;
|
||||
}
|
||||
|
||||
unset(self::$instances[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
|
||||
*
|
||||
@@ -200,11 +247,11 @@ class ProductPriceTableMap extends TableMap
|
||||
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
// If the PK cannot be derived from the row, return NULL.
|
||||
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
|
||||
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,11 +269,7 @@ class ProductPriceTableMap extends TableMap
|
||||
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
|
||||
return (int) $row[
|
||||
$indexType == TableMap::TYPE_NUM
|
||||
? 0 + $offset
|
||||
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
|
||||
];
|
||||
return $pks;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +367,6 @@ class ProductPriceTableMap extends TableMap
|
||||
public static function addSelectColumns(Criteria $criteria, $alias = null)
|
||||
{
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(ProductPriceTableMap::ID);
|
||||
$criteria->addSelectColumn(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID);
|
||||
$criteria->addSelectColumn(ProductPriceTableMap::CURRENCY_ID);
|
||||
$criteria->addSelectColumn(ProductPriceTableMap::PRICE);
|
||||
@@ -332,7 +374,6 @@ class ProductPriceTableMap extends TableMap
|
||||
$criteria->addSelectColumn(ProductPriceTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(ProductPriceTableMap::UPDATED_AT);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_ID');
|
||||
$criteria->addSelectColumn($alias . '.CURRENCY_ID');
|
||||
$criteria->addSelectColumn($alias . '.PRICE');
|
||||
@@ -390,7 +431,17 @@ class ProductPriceTableMap extends TableMap
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else { // it's a primary key, or an array of pks
|
||||
$criteria = new Criteria(ProductPriceTableMap::DATABASE_NAME);
|
||||
$criteria->add(ProductPriceTableMap::ID, (array) $values, Criteria::IN);
|
||||
// primary key is composite; we therefore, expect
|
||||
// the primary key passed to be an array of pkey values
|
||||
if (count($values) == count($values, COUNT_RECURSIVE)) {
|
||||
// array is not multi-dimensional
|
||||
$values = array($values);
|
||||
}
|
||||
foreach ($values as $value) {
|
||||
$criterion = $criteria->getNewCriterion(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $value[0]);
|
||||
$criterion->addAnd($criteria->getNewCriterion(ProductPriceTableMap::CURRENCY_ID, $value[1]));
|
||||
$criteria->addOr($criterion);
|
||||
}
|
||||
}
|
||||
|
||||
$query = ProductPriceQuery::create()->mergeWith($criteria);
|
||||
@@ -436,10 +487,6 @@ class ProductPriceTableMap extends TableMap
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from ProductPrice object
|
||||
}
|
||||
|
||||
if ($criteria->containsKey(ProductPriceTableMap::ID) && $criteria->keyContainsValue(ProductPriceTableMap::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductPriceTableMap::ID.')');
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = ProductPriceQuery::create()->mergeWith($criteria);
|
||||
|
||||
@@ -7,6 +7,7 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`date_format`,`time_format
|
||||
INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES
|
||||
('session_config.default', '1', 1, 1, NOW(), NOW()),
|
||||
('verifyStock', '1', 0, 0, NOW(), NOW()),
|
||||
('active-template', 'default', 0, 0, NOW(), NOW()),
|
||||
('default_lang_without_translation', '1', 0, 0, NOW(), NOW()),
|
||||
('rewriting_enable', '0', 0, 0, NOW(), NOW()),
|
||||
('imagine_graphic_driver', 'gd', 0, 0, NOW(), NOW()),
|
||||
@@ -15,7 +16,8 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
|
||||
('images_library_path', 'local/media/images', 0, 0, NOW(), NOW()),
|
||||
('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()),
|
||||
('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()),
|
||||
('page_not_found_view', '404.html', 0, 0, NOW(), NOW());
|
||||
('page_not_found_view', '404.html', 0, 0, NOW(), NOW()),
|
||||
('use_tax_free_amounts', 1, 1, 0, NOW(), NOW());
|
||||
|
||||
|
||||
INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES
|
||||
|
||||
@@ -1213,14 +1213,13 @@ DROP TABLE IF EXISTS `product_price`;
|
||||
|
||||
CREATE TABLE `product_price`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`product_sale_elements_id` INTEGER NOT NULL,
|
||||
`currency_id` INTEGER NOT NULL,
|
||||
`price` FLOAT NOT NULL,
|
||||
`promo_price` FLOAT,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`),
|
||||
PRIMARY KEY (`product_sale_elements_id`,`currency_id`),
|
||||
INDEX `idx_product_price_product_sale_elements_id` (`product_sale_elements_id`),
|
||||
INDEX `idx_product_price_currency_id` (`currency_id`),
|
||||
CONSTRAINT `fk_product_price_product_sale_elements_id`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="thelia">
|
||||
<table name="category" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
@@ -924,9 +924,8 @@
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table name="product_price" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="product_sale_elements_id" required="true" type="INTEGER" />
|
||||
<column name="currency_id" required="true" type="INTEGER" />
|
||||
<column name="product_sale_elements_id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="currency_id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="price" required="true" type="FLOAT" />
|
||||
<column name="promo_price" type="FLOAT" />
|
||||
<foreign-key foreignTable="product_sale_elements" name="fk_product_price_product_sale_elements_id" onDelete="CASCADE">
|
||||
|
||||
@@ -115,14 +115,52 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function log($level, $message, array $context = array())
|
||||
{
|
||||
list($sql, $duration_str) = $this->parseAndLogSqlQuery($message);
|
||||
|
||||
$message = "$sql ($duration_str)";
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a log line to extract query information
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
protected function parseAndLogSqlQuery($message)
|
||||
{
|
||||
$parts = explode('|', $message, 3);
|
||||
$duration = 0;
|
||||
$memory = 0;
|
||||
if (count($parts) > 1) {
|
||||
$sql = trim($parts[2]);
|
||||
|
||||
if (preg_match('/([0-9]+\.[0-9]+)/', $parts[0], $matches)) {
|
||||
$duration = (float) $matches[1];
|
||||
}
|
||||
|
||||
if (preg_match('/([0-9]+\.[0-9]+)([A-Z]{1,2})/', $parts[1], $matches)) {
|
||||
$memory = (float) $matches[1];
|
||||
if ($matches[2] == 'KB') {
|
||||
$memory *= 1024;
|
||||
} else if ($matches[2] == 'MB') {
|
||||
$memory *= 1024 * 1024;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql = $parts[0];
|
||||
}
|
||||
|
||||
|
||||
$this->statements[] = array(
|
||||
'sql' => $message,
|
||||
'sql' => $sql,
|
||||
'is_success' => true,
|
||||
'duration' => 0,
|
||||
'duration_str' => $this->formatDuration(1),
|
||||
'memory' => 1,
|
||||
'memory_str' => $this->formatBytes(1)
|
||||
'duration' => $duration,
|
||||
'duration_str' => $this->formatDuration($duration),
|
||||
'memory' => $memory,
|
||||
'memory_str' => $this->formatBytes($memory)
|
||||
);
|
||||
$this->accumulatedTime += $duration;
|
||||
$this->peakMemory = max($this->peakMemory, $memory);
|
||||
return array($sql, $this->formatDuration($duration));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\Smarty\an;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use DebugBar\DebugBar as BaseDebugBar;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class DebugBar
|
||||
@@ -52,12 +53,63 @@ class DebugBar extends AbstractSmartyPlugin
|
||||
return $render;
|
||||
}
|
||||
|
||||
public function renderCss($params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$render = "";
|
||||
if($this->debugMode)
|
||||
{
|
||||
$webFile = "cache/debugbar.css";
|
||||
$cssFile = THELIA_WEB_DIR ."/".$webFile;
|
||||
|
||||
if(!file_exists($cssFile)) {
|
||||
$javascriptRenderer = $this->debugBar->getJavascriptRenderer();
|
||||
$assetCss = $javascriptRenderer->getAsseticCollection("css");
|
||||
|
||||
foreach($assetCss->all() as $asset) {
|
||||
if(strpos($asset->getSourcePath(), "font-awesome") !== false) {
|
||||
$assetCss->removeLeaf($asset);
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($cssFile, $assetCss->dump());
|
||||
}
|
||||
$render = sprintf('<link rel="stylesheet" href="%s">', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE));
|
||||
}
|
||||
return $render;
|
||||
}
|
||||
|
||||
public function renderJs($params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$render = "";
|
||||
if($this->debugMode)
|
||||
{
|
||||
$webFile = "cache/debugbar.js";
|
||||
$cacheFile = THELIA_WEB_DIR ."/".$webFile;
|
||||
|
||||
if (!file_exists($cacheFile)) {
|
||||
$javascriptRenderer = $this->debugBar->getJavascriptRenderer();
|
||||
$assetJs = $javascriptRenderer->getAsseticCollection("js");
|
||||
|
||||
foreach($assetJs->all() as $asset) {
|
||||
if(strpos($asset->getSourcePath(), "jquery") !== false) {
|
||||
$assetJs->removeLeaf($asset);
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($cacheFile, $assetJs->dump());
|
||||
}
|
||||
|
||||
$render = sprintf('<script src="%s"></script>', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE));
|
||||
}
|
||||
return $render;
|
||||
}
|
||||
|
||||
public function renderHead($params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$render = "";
|
||||
if ($this->debugMode) {
|
||||
$javascriptRenderer = $this->debugBar->getJavascriptRenderer();
|
||||
$assets = $javascriptRenderer->getAsseticCollection();
|
||||
$assets = $javascriptRenderer->getAssets();
|
||||
|
||||
$cssCollection = $assets[0];
|
||||
$jsCollection = $assets[1];
|
||||
@@ -75,8 +127,9 @@ class DebugBar extends AbstractSmartyPlugin
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor("function", "debugbar_renderHead", $this, "renderHead"),
|
||||
new SmartyPluginDescriptor("function", "debugbar_render", $this, "render")
|
||||
new SmartyPluginDescriptor("function", "debugbar_rendercss", $this, "renderCss"),
|
||||
new SmartyPluginDescriptor("function", "debugbar_renderjs", $this, "renderJs"),
|
||||
new SmartyPluginDescriptor("function", "debugbar_renderresult", $this, "render")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ Parameters:
|
||||
{* re-display the form creation dialog if it contains errors *}
|
||||
|
||||
{form name="{$form_name}"}
|
||||
{if #form_error}
|
||||
{if $form_error}
|
||||
$('#{$dialog_id}').modal();
|
||||
{/if}
|
||||
{/form}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
{loop type="feed" name="thelia_feeds" url="http://thelia.net/Flux-rss.html?id_rubrique=8" limit="3"}
|
||||
<div class="span4 feed-list-item">
|
||||
<h3>{$DATE}</h3>
|
||||
<h2><a href="#URL" target="_blank" title="{intl l='Lire la suite'}">{$TITLE|strip_tags}</a></h2>
|
||||
<h2><a href="{$URL}" target="_blank" title="{intl l='Lire la suite'}">{$TITLE|strip_tags}</a></h2>
|
||||
<p>{$DESCRIPTION|strip_tags|truncate:250:"...":true}</p>
|
||||
<p><a class="btn" href="#URL" target="_blank">{intl l='Lire la suite »'}</a></p>
|
||||
<p><a class="btn" href="{$URL}" target="_blank">{intl l='Lire la suite »'}</a></p>
|
||||
</div>
|
||||
{/loop}
|
||||
|
||||
@@ -30,7 +30,7 @@ URL: http://www.thelia.net
|
||||
{stylesheets file='assets/less/styles.less' filters='less,cssembed'}
|
||||
<link rel="stylesheet" href="{$asset_url}">
|
||||
{/stylesheets}
|
||||
|
||||
{debugbar_rendercss}
|
||||
{block name="stylesheet"}{/block}
|
||||
</head>
|
||||
|
||||
@@ -397,6 +397,9 @@ URL: http://www.thelia.net
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
{debugbar_renderjs}
|
||||
{debugbar_renderresult}
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
@@ -13,7 +13,7 @@ Index : {navigate to="index"}<br />
|
||||
<h3>{$TITLE}</h3>
|
||||
<p>{$DESCRIPTION}</p>
|
||||
|
||||
<p>Starting by {$BEST_PRICE} € HT (TAX : {$BEST_PRICE_TAX} ; {$BEST_TAXED_PRICE} € TTC)</p>
|
||||
<p>Starting by {$BEST_PRICE} {currency attr="symbol"} HT (TAX : {$BEST_PRICE_TAX} ; {$BEST_TAXED_PRICE} {currency attr="symbol"} TTC)</p>
|
||||
|
||||
{ifloop rel="acc"}
|
||||
<h4>Accessories</h4>
|
||||
@@ -66,7 +66,7 @@ Index : {navigate to="index"}<br />
|
||||
{$ATTRIBUTE_TITLE} = {$ATTRIBUTE_AVAILABILITY_TITLE}<br />
|
||||
{/loop}
|
||||
<br />{$WEIGHT} g
|
||||
<br /><strong>{if $IS_PROMO == 1} {$PROMO_PRICE} € HT // TAX : {$PROMO_PRICE_TAX} ; {$TAXED_PROMO_PRICE} € TTC (instead of {$PRICE HT} // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} € TTC){else} {$PRICE} € HT // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} € TTC{/if}</strong>
|
||||
<br /><strong>{if $IS_PROMO == 1} {$PROMO_PRICE} {currency attr="symbol"} HT // TAX : {$PROMO_PRICE_TAX} ; {$TAXED_PROMO_PRICE} {currency attr="symbol"} TTC (instead of {$PRICE HT} // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} {currency attr="symbol"} TTC){else} {$PRICE} {currency attr="symbol"} HT // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} {currency attr="symbol"} TTC{/if}</strong>
|
||||
<br /><br />
|
||||
Add
|
||||
<select>
|
||||
|
||||
Reference in New Issue
Block a user