Merge branch 'master' of https://github.com/thelia/thelia
This commit is contained in:
0
core/lib/Thelia/Action/BaseAction.php
Normal file → Executable file
0
core/lib/Thelia/Action/BaseAction.php
Normal file → Executable file
0
core/lib/Thelia/Action/Category.php
Normal file → Executable file
0
core/lib/Thelia/Action/Category.php
Normal file → Executable file
0
core/lib/Thelia/Action/Image.php
Normal file → Executable file
0
core/lib/Thelia/Action/Image.php
Normal file → Executable file
0
core/lib/Thelia/Cart/CartTrait.php
Normal file → Executable file
0
core/lib/Thelia/Cart/CartTrait.php
Normal file → Executable file
0
core/lib/Thelia/Command/BaseModuleGenerate.php
Normal file → Executable file
0
core/lib/Thelia/Command/BaseModuleGenerate.php
Normal file → Executable file
0
core/lib/Thelia/Command/ClearImageCache.php
Normal file → Executable file
0
core/lib/Thelia/Command/ClearImageCache.php
Normal file → Executable file
0
core/lib/Thelia/Command/ModuleGenerateCommand.php
Normal file → Executable file
0
core/lib/Thelia/Command/ModuleGenerateCommand.php
Normal file → Executable file
0
core/lib/Thelia/Command/ModuleGenerateModelCommand.php
Normal file → Executable file
0
core/lib/Thelia/Command/ModuleGenerateModelCommand.php
Normal file → Executable file
0
core/lib/Thelia/Command/ModuleGenerateSqlCommand.php
Normal file → Executable file
0
core/lib/Thelia/Command/ModuleGenerateSqlCommand.php
Normal file → Executable file
0
core/lib/Thelia/Command/Output/TheliaConsoleOutput.php
Normal file → Executable file
0
core/lib/Thelia/Command/Output/TheliaConsoleOutput.php
Normal file → Executable file
0
core/lib/Thelia/Command/Skeleton/Module/Class.php
Normal file → Executable file
0
core/lib/Thelia/Command/Skeleton/Module/Class.php
Normal file → Executable file
0
core/lib/Thelia/Command/Skeleton/Module/config.xml
Normal file → Executable file
0
core/lib/Thelia/Command/Skeleton/Module/config.xml
Normal file → Executable file
0
core/lib/Thelia/Command/Skeleton/Module/plugin.xml
Normal file → Executable file
0
core/lib/Thelia/Command/Skeleton/Module/plugin.xml
Normal file → Executable file
0
core/lib/Thelia/Command/Skeleton/Module/schema.xml
Normal file → Executable file
0
core/lib/Thelia/Command/Skeleton/Module/schema.xml
Normal file → Executable file
@@ -7,19 +7,24 @@
|
||||
<loops>
|
||||
<loop class="Thelia\Core\Template\Loop\Accessory" name="accessory"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Address" name="address"/>
|
||||
<loop class="Thelia\Core\Template\Loop\AssociatedContent" name="associated_content"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Attribute" name="attribute"/>
|
||||
<loop class="Thelia\Core\Template\Loop\AttributeAvailability" name="attribute_availability"/>
|
||||
<loop class="Thelia\Core\Template\Loop\AttributeCombination" name="attribute_combination"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Auth" name="auth"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Category" name="category"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Content" name="content"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Country" name="country"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Customer" name="customer"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Feature" name="feature"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureAvailable" name="feature_available"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureAvailability" name="feature_availability"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureValue" name="feature_value"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Folder" name="folder"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Order" name="order"/>
|
||||
<loop class="Thelia\Core\Template\Loop\OrderStatus" name="order-status"/>
|
||||
<loop class="Thelia\Core\Template\Loop\CategoryPath" name="category-path"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Product" name="product"/>
|
||||
<loop class="Thelia\Core\Template\Loop\ProductSaleElements" name="product_sale_elements"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Feed" name="feed"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Title" name="title"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Lang" name="lang"/>
|
||||
|
||||
0
core/lib/Thelia/Config/Resources/routing/front.xml
Normal file → Executable file
0
core/lib/Thelia/Config/Resources/routing/front.xml
Normal file → Executable file
0
core/lib/Thelia/Controller/Admin/BaseAdminController.php
Normal file → Executable file
0
core/lib/Thelia/Controller/Admin/BaseAdminController.php
Normal file → Executable file
0
core/lib/Thelia/Controller/Admin/CategoryController.php
Normal file → Executable file
0
core/lib/Thelia/Controller/Admin/CategoryController.php
Normal file → Executable file
0
core/lib/Thelia/Controller/Front/BaseFrontController.php
Normal file → Executable file
0
core/lib/Thelia/Controller/Front/BaseFrontController.php
Normal file → Executable file
0
core/lib/Thelia/Controller/Front/CartController.php
Normal file → Executable file
0
core/lib/Thelia/Controller/Front/CartController.php
Normal file → Executable file
0
core/lib/Thelia/Controller/Front/CustomerController.php
Normal file → Executable file
0
core/lib/Thelia/Controller/Front/CustomerController.php
Normal file → Executable file
0
core/lib/Thelia/Core/Context.php
Normal file → Executable file
0
core/lib/Thelia/Core/Context.php
Normal file → Executable file
0
core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterRouterPass.php
Normal file → Executable file
0
core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterRouterPass.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CartEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CartEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CartItemEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CartItemEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CategoryEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CategoryEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CustomerCreateOrUpdateEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CustomerCreateOrUpdateEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CustomerLoginEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/CustomerLoginEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/ImageEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/ImageEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/Internal/CartEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/Internal/CartEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/Internal/CustomerEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/Internal/CustomerEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/Internal/InternalEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Event/Internal/InternalEvent.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Authentication/AuthenticatorInterface.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Authentication/AuthenticatorInterface.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Exception/AuthenticationException.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Exception/AuthenticationException.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Exception/AuthorizationException.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Exception/AuthorizationException.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Exception/UsernameNotFoundException.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Exception/UsernameNotFoundException.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Exception/WrongPasswordException.php
Normal file → Executable file
0
core/lib/Thelia/Core/Security/Exception/WrongPasswordException.php
Normal file → Executable file
@@ -187,8 +187,8 @@ abstract class BaseLoop
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ModelCriteria $search
|
||||
* @param null $pagination
|
||||
* @param ModelCriteria $search
|
||||
* @param null $pagination
|
||||
*
|
||||
* @return array|mixed|\PropelModelPager|\PropelObjectCollection
|
||||
*/
|
||||
@@ -202,7 +202,7 @@ abstract class BaseLoop
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ModelCriteria $search
|
||||
* @param ModelCriteria $search
|
||||
*
|
||||
* @return array|mixed|\PropelObjectCollection
|
||||
*/
|
||||
|
||||
128
core/lib/Thelia/Core/Template/Loop/AssociatedContent.php
Executable file
128
core/lib/Thelia/Core/Template/Loop/AssociatedContent.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Thelia\Core\Template\Loop\Content;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\ProductAssociatedContentQuery;
|
||||
use Thelia\Model\CategoryAssociatedContentQuery;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* AssociatedContent loop
|
||||
*
|
||||
*
|
||||
* Class AssociatedContent
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class AssociatedContent extends Content
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
$argumentCollection = parent::getArgDefinitions();
|
||||
|
||||
$argumentCollection->addArgument(Argument::createIntTypeArgument('product'))
|
||||
->addArgument(Argument::createIntTypeArgument('category'));
|
||||
|
||||
$argumentCollection->get('order')->default = "associated_content";
|
||||
|
||||
$argumentCollection->get('order')->type->getKey(0)->addValue('associated_content');
|
||||
$argumentCollection->get('order')->type->getKey(0)->addValue('associated_content_reverse');
|
||||
|
||||
return $argumentCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return LoopResult
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
//
|
||||
|
||||
$product = $this->getProduct();
|
||||
$category = $this->getCategory();
|
||||
|
||||
if($product === null && $category === null) {
|
||||
throw new \InvalidArgumentException('You have to provide either `product` or `category` argument in associated_content loop');
|
||||
}
|
||||
|
||||
if($product !== null) {
|
||||
$search = ProductAssociatedContentQuery::create();
|
||||
|
||||
$search->filterByProductId($product, Criteria::EQUAL);
|
||||
} elseif($category !== null) {
|
||||
$search = CategoryAssociatedContentQuery::create();
|
||||
|
||||
$search->filterByCategoryId($category, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$order = $this->getOrder();
|
||||
$orderByAssociatedContent = array_search('associated_content', $order);
|
||||
$orderByAssociatedContentReverse = array_search('associated_content_reverse', $order);
|
||||
|
||||
if ($orderByAssociatedContent !== false) {
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
$order[$orderByAssociatedContent] = 'given_id';
|
||||
$this->args->get('order')->setValue( implode(',', $order) );
|
||||
}
|
||||
if ($orderByAssociatedContentReverse !== false) {
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
$order[$orderByAssociatedContentReverse] = 'given_id';
|
||||
$this->args->get('order')->setValue( implode(',', $order) );
|
||||
}
|
||||
|
||||
$associatedContents = $this->search($search);
|
||||
|
||||
$associatedContentIdList = array(0);
|
||||
foreach ($associatedContents as $associatedContent) {
|
||||
array_push($associatedContentIdList, $associatedContent->getContentId());
|
||||
}
|
||||
|
||||
$receivedIdList = $this->getId();
|
||||
|
||||
/* if an Id list is receive, loop will only match accessories from this list */
|
||||
if ($receivedIdList === null) {
|
||||
$this->args->get('id')->setValue( implode(',', $associatedContentIdList) );
|
||||
} else {
|
||||
$this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $associatedContentIdList)) );
|
||||
}
|
||||
|
||||
return parent::exec($pagination);
|
||||
}
|
||||
|
||||
}
|
||||
164
core/lib/Thelia/Core/Template/Loop/Attribute.php
Executable file
164
core/lib/Thelia/Core/Template/Loop/Attribute.php
Executable file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\CategoryQuery;
|
||||
use Thelia\Model\Base\ProductCategoryQuery;
|
||||
use Thelia\Model\Base\AttributeQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Map\ProductCategoryTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
*
|
||||
* Attribute loop
|
||||
*
|
||||
*
|
||||
* Class Attribute
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Attribute extends BaseLoop
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('product'),
|
||||
Argument::createIntListTypeArgument('category'),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
|
||||
),
|
||||
'manual'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = AttributeQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (null !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$visible = $this->getVisible();
|
||||
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
$product = $this->getProduct();
|
||||
$category = $this->getCategory();
|
||||
|
||||
if(null !== $product) {
|
||||
$productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData();
|
||||
|
||||
if(null === $category) {
|
||||
$category = $productCategories;
|
||||
} else {
|
||||
$category = array_merge($category, $productCategories);
|
||||
}
|
||||
}
|
||||
|
||||
if(null !== $category) {
|
||||
$search->filterByCategory(
|
||||
CategoryQuery::create()->filterById($category)->find(),
|
||||
Criteria::IN
|
||||
);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual":
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "manual_reverse":
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$attributes = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $attribute->getId())
|
||||
->set("TITLE",$attribute->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $attribute->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $attribute->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $attribute->getVirtualColumn('i18n_POSTSCRIPTUM'));
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
139
core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php
Executable file
139
core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php
Executable file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\AttributeAvQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
* AttributeAvailability loop
|
||||
*
|
||||
*
|
||||
* Class AttributeAvailability
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class AttributeAvailability extends BaseLoop
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('attribute'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
|
||||
),
|
||||
'manual'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = AttributeAvQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (null !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$attribute = $this->getAttribute();
|
||||
|
||||
if(null !== $attribute) {
|
||||
$search->filterByAttributeId($attribute, Criteria::IN);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual":
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "manual_reverse":
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$attributesAv = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($attributesAv as $attributeAv) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $attributeAv->getId())
|
||||
->set("TITLE",$attributeAv->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $attributeAv->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $attributeAv->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $attributeAv->getVirtualColumn('i18n_POSTSCRIPTUM'));
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
140
core/lib/Thelia/Core/Template/Loop/AttributeCombination.php
Executable file
140
core/lib/Thelia/Core/Template/Loop/AttributeCombination.php
Executable file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\AttributeCombinationQuery;
|
||||
use Thelia\Model\Map\AttributeAvTableMap;
|
||||
use Thelia\Model\Map\AttributeTableMap;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* Attribute Combination loop
|
||||
*
|
||||
* Class AttributeCombination
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class AttributeCombination extends BaseLoop
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('product_sale_elements', null, true),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse'))
|
||||
),
|
||||
'alpha'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = AttributeCombinationQuery::create();
|
||||
|
||||
/* manage attribute translations */
|
||||
ModelCriteriaTools::getI18n(
|
||||
$search,
|
||||
ConfigQuery::read("default_lang_without_translation", 1),
|
||||
$this->request->getSession()->getLocale(),
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
AttributeTableMap::TABLE_NAME,
|
||||
'ATTRIBUTE_ID'
|
||||
);
|
||||
|
||||
/* manage attributeAv translations */
|
||||
ModelCriteriaTools::getI18n(
|
||||
$search,
|
||||
ConfigQuery::read("default_lang_without_translation", 1),
|
||||
$this->request->getSession()->getLocale(),
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
AttributeAvTableMap::TABLE_NAME,
|
||||
'ATTRIBUTE_AV_ID'
|
||||
);
|
||||
|
||||
$productSaleElements = $this->getProduct_sale_elements();
|
||||
|
||||
$search->filterByProductSaleElementsId($productSaleElements, Criteria::EQUAL);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE');
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$attributeCombinations = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($attributeCombinations as $attributeCombination) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("ATTRIBUTE_TITLE", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE'))
|
||||
->set("ATTRIBUTE_CHAPO", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_CHAPO'))
|
||||
->set("ATTRIBUTE_DESCRIPTION", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
|
||||
->set("ATTRIBUTE_POSTSCRIPTUM", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM'))
|
||||
->set("ATTRIBUTE_AVAILABILITY_TITLE", $attributeCombination->getVirtualColumn(AttributeAvTableMap::TABLE_NAME . '_i18n_TITLE'))
|
||||
->set("ATTRIBUTE_AVAILABILITY_CHAPO", $attributeCombination->getVirtualColumn(AttributeAvTableMap::TABLE_NAME . '_i18n_CHAPO'))
|
||||
->set("ATTRIBUTE_AVAILABILITY_DESCRIPTION", $attributeCombination->getVirtualColumn(AttributeAvTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
|
||||
->set("ATTRIBUTE_AVAILABILITY_POSTSCRIPTUM", $attributeCombination->getVirtualColumn(AttributeAvTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM'));
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
0
core/lib/Thelia/Core/Template/Loop/Cart.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/Cart.php
Normal file → Executable file
@@ -30,6 +30,9 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
@@ -46,7 +49,7 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* - current : current id is used if you are on a category page
|
||||
* - not_empty : if value is 1, category and subcategories must have at least 1 product
|
||||
* - visible : default 1, if you want category not visible put 0
|
||||
* - order : all value available : 'alpha', 'alpha-reverse', 'manual' (default), 'manual-reverse', 'random'
|
||||
* - order : all value available : 'alpha', 'alpha_reverse', 'manual' (default), 'manual_reverse', 'random'
|
||||
* - exclude : all category id you want to exclude (as for id, an integer or a "string list" can be used)
|
||||
*
|
||||
* example :
|
||||
@@ -77,7 +80,7 @@ class Category extends BaseLoop
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual-reverse', 'random'))
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'random'))
|
||||
),
|
||||
'manual'
|
||||
),
|
||||
@@ -94,7 +97,10 @@ class Category extends BaseLoop
|
||||
{
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
$id = $this->getId();
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (!is_null($id)) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
@@ -106,7 +112,8 @@ class Category extends BaseLoop
|
||||
$search->filterByParent($parent);
|
||||
}
|
||||
|
||||
$current = $this->getCurrent();
|
||||
|
||||
$current = $this->getCurrent();
|
||||
|
||||
if ($current === true) {
|
||||
$search->filterById($this->request->get("category_id"));
|
||||
@@ -114,6 +121,7 @@ class Category extends BaseLoop
|
||||
$search->filterById($this->request->get("category_id"), Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
@@ -121,19 +129,19 @@ class Category extends BaseLoop
|
||||
}
|
||||
|
||||
if ($this->getVisible() != BooleanOrBothType::ANY)
|
||||
$search->filterByVisible($this->getVisible() ? 1 : 0);
|
||||
$search->filterByVisible($this->getVisible() ? 1 : 0);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE);
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha-reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE);
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual-reverse":
|
||||
case "manual_reverse":
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
case "manual":
|
||||
@@ -147,51 +155,45 @@ class Category extends BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
/* perform search */
|
||||
$categories = $this->search($search, $pagination);
|
||||
|
||||
/* @todo */
|
||||
$notEmpty = $this->getNot_empty();
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue;
|
||||
/*
|
||||
* no cause pagination lost :
|
||||
* if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue;
|
||||
*/
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $category->getId())
|
||||
->set("TITLE",$category->getTitle())
|
||||
->set("CHAPO", $category->getChapo())
|
||||
->set("DESCRIPTION", $category->getDescription())
|
||||
->set("POSTSCRIPTUM", $category->getPostscriptum())
|
||||
->set("PARENT", $category->getParent())
|
||||
->set("URL", $category->getUrl())
|
||||
->set("PRODUCT_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $category->getPosition())
|
||||
->set("ID", $category->getId())
|
||||
->set("TITLE",$category->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $category->getParent())
|
||||
->set("URL", $category->getUrl())
|
||||
->set("PRODUCT_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $category->getPosition())
|
||||
|
||||
->set("CREATE_DATE", $category->getCreatedAt())
|
||||
->set("UPDATE_DATE", $category->getUpdatedAt())
|
||||
->set("VERSION", $category->getVersion())
|
||||
->set("VERSION_DATE", $category->getVersionCreatedAt())
|
||||
->set("VERSION_AUTHOR", $category->getVersionCreatedBy())
|
||||
;
|
||||
->set("CREATE_DATE", $category->getCreatedAt())
|
||||
->set("UPDATE_DATE", $category->getUpdatedAt())
|
||||
->set("VERSION", $category->getVersion())
|
||||
->set("VERSION_DATE", $category->getVersionCreatedAt())
|
||||
->set("VERSION_AUTHOR", $category->getVersionCreatedBy())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
0
core/lib/Thelia/Core/Template/Loop/CategoryPath.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/CategoryPath.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/CategoryTree.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/CategoryTree.php
Normal file → Executable file
@@ -31,6 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\Map\ContentTableMap;
|
||||
use Thelia\Model\ContentFolderQuery;
|
||||
@@ -85,6 +87,9 @@ class Content extends BaseLoop
|
||||
{
|
||||
$search = ContentQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (!is_null($id)) {
|
||||
@@ -153,10 +158,10 @@ class Content extends BaseLoop
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\ContentI18nTableMap::TITLE);
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha-reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\Map\ContentI18nTableMap::TITLE);
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual":
|
||||
if(null === $folder || count($folder) != 1)
|
||||
@@ -199,17 +204,7 @@ class Content extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
/* perform search */
|
||||
$search->groupBy(ContentTableMap::ID);
|
||||
|
||||
$contents = $this->search($search, $pagination);
|
||||
@@ -220,10 +215,10 @@ class Content extends BaseLoop
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow->set("ID", $content->getId())
|
||||
->set("TITLE",$content->getTitle())
|
||||
->set("CHAPO", $content->getChapo())
|
||||
->set("DESCRIPTION", $content->getDescription())
|
||||
->set("POSTSCRIPTUM", $content->getPostscriptum())
|
||||
->set("TITLE",$content->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $content->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("POSITION", $content->getPosition())
|
||||
;
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
@@ -51,7 +53,6 @@ class Country extends BaseLoop
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('limit', 500), // overwrite orginal param to increase the limit
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('area'),
|
||||
Argument::createBooleanTypeArgument('with_area'),
|
||||
@@ -68,6 +69,9 @@ class Country extends BaseLoop
|
||||
{
|
||||
$search = CountryQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
@@ -94,31 +98,20 @@ class Country extends BaseLoop
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\CountryI18nTableMap::TITLE);
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
|
||||
/* perform search */
|
||||
$countries = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($countries as $country) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $country->getId());
|
||||
$loopResultRow->set("AREA", $country->getAreaId());
|
||||
$loopResultRow->set("TITLE", $country->getTitle());
|
||||
$loopResultRow->set("CHAPO", $country->getChapo());
|
||||
$loopResultRow->set("DESCRIPTION", $country->getDescription());
|
||||
$loopResultRow->set("POSTSCRIPTUM", $country->getPostscriptum());
|
||||
$loopResultRow->set("ID", $country->getId())
|
||||
->set("TITLE",$country->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $country->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $country->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $country->getVirtualColumn('i18n_POSTSCRIPTUM'));
|
||||
$loopResultRow->set("ISOCODE", $country->getIsocode());
|
||||
$loopResultRow->set("ISOALPHA2", $country->getIsoalpha2());
|
||||
$loopResultRow->set("ISOALPHA3", $country->getIsoalpha3());
|
||||
|
||||
112
core/lib/Thelia/Core/Template/Loop/Currency.php
Executable file
112
core/lib/Thelia/Core/Template/Loop/Currency.php
Executable file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* Currency loop
|
||||
*
|
||||
*
|
||||
* Class Currency
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Currency extends BaseLoop
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
Argument::createBooleanTypeArgument('default_only', false)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('NAME'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$default_only = $this->getDefaultOnly();
|
||||
|
||||
if ($default_only === true) {
|
||||
$search->filterByByDefault(true);
|
||||
}
|
||||
|
||||
$search->orderByPosition();
|
||||
|
||||
/* perform search */
|
||||
$currencies = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $currency->getId())
|
||||
->set("NAME",$currency->getVirtualColumn('i18n_NAME'))
|
||||
->set("ISOCODE", $currency->getCode())
|
||||
->set("RATE", $currency->getRate())
|
||||
->set("IS_DEFAULT", $currency->getByDefault());
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\CategoryQuery;
|
||||
use Thelia\Model\Base\ProductCategoryQuery;
|
||||
use Thelia\Model\Base\FeatureQuery;
|
||||
@@ -81,6 +83,9 @@ class Feature extends BaseLoop
|
||||
{
|
||||
$search = FeatureQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
@@ -122,10 +127,10 @@ class Feature extends BaseLoop
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE);
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha-reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE);
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual":
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
@@ -136,28 +141,18 @@ class Feature extends BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
/* perform search */
|
||||
$features = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($features as $feature) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $feature->getId());
|
||||
$loopResultRow->set("TITLE",$feature->getTitle());
|
||||
$loopResultRow->set("CHAPO", $feature->getChapo());
|
||||
$loopResultRow->set("DESCRIPTION", $feature->getDescription());
|
||||
$loopResultRow->set("POSTSCRIPTUM", $feature->getPostscriptum());
|
||||
$loopResultRow->set("ID", $feature->getId())
|
||||
->set("TITLE",$feature->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM'));
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -31,21 +31,22 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\FeatureAvQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*todo : to be finished
|
||||
* FeatureAvailable loop
|
||||
* FeatureAvailability loop
|
||||
*
|
||||
*
|
||||
* Class FeatureAvailable
|
||||
* Class FeatureAvailability
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class FeatureAvailable extends BaseLoop
|
||||
class FeatureAvailability extends BaseLoop
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -75,6 +76,9 @@ class FeatureAvailable extends BaseLoop
|
||||
{
|
||||
$search = FeatureAvQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
@@ -98,10 +102,10 @@ class FeatureAvailable extends BaseLoop
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\FeatureAvI18nTableMap::TITLE);
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha-reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\Map\FeatureAvI18nTableMap::TITLE);
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual":
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
@@ -112,28 +116,18 @@ class FeatureAvailable extends BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
/* perform search */
|
||||
$featuresAv = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($featuresAv as $featureAv) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $featureAv->getId());
|
||||
$loopResultRow->set("TITLE",$featureAv->getTitle());
|
||||
$loopResultRow->set("CHAPO", $featureAv->getChapo());
|
||||
$loopResultRow->set("DESCRIPTION", $featureAv->getDescription());
|
||||
$loopResultRow->set("POSTSCRIPTUM", $featureAv->getPostscriptum());
|
||||
$loopResultRow->set("ID", $featureAv->getId())
|
||||
->set("TITLE",$featureAv->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $featureAv->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $featureAv->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $featureAv->getVirtualColumn('i18n_POSTSCRIPTUM'));
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
@@ -24,15 +24,21 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\FeatureProductQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Map\FeatureAvTableMap;
|
||||
use Thelia\Model\Map\FeatureProductTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -55,13 +61,13 @@ class FeatureValue extends BaseLoop
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('feature', null, true),
|
||||
Argument::createIntTypeArgument('product', null, true),
|
||||
Argument::createIntListTypeArgument('feature_available'),
|
||||
Argument::createBooleanTypeArgument('exclude_feature_available', 0),
|
||||
Argument::createBooleanTypeArgument('exclude_default_values', 0),
|
||||
Argument::createIntListTypeArgument('feature_availability'),
|
||||
Argument::createBooleanTypeArgument('exclude_feature_availability', 0),
|
||||
Argument::createBooleanTypeArgument('exclude_personal_values', 0),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual_reverse'))
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
|
||||
),
|
||||
'manual'
|
||||
)
|
||||
@@ -77,6 +83,16 @@ class FeatureValue extends BaseLoop
|
||||
{
|
||||
$search = FeatureProductQuery::create();
|
||||
|
||||
/* manage featureAv translations */
|
||||
ModelCriteriaTools::getI18n(
|
||||
$search,
|
||||
ConfigQuery::read("default_lang_without_translation", 1),
|
||||
$this->request->getSession()->getLocale(),
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
FeatureAvTableMap::TABLE_NAME,
|
||||
'FEATURE_AV_ID'
|
||||
);
|
||||
|
||||
$feature = $this->getFeature();
|
||||
|
||||
$search->filterByFeatureId($feature, Criteria::EQUAL);
|
||||
@@ -85,31 +101,31 @@ class FeatureValue extends BaseLoop
|
||||
|
||||
$search->filterByProductId($product, Criteria::EQUAL);
|
||||
|
||||
$featureAvailable = $this->getFeature_available();
|
||||
$featureAvailability = $this->getFeature_availability();
|
||||
|
||||
if (null !== $featureAvailable) {
|
||||
$search->filterByFeatureAvId($featureAvailable, Criteria::IN);
|
||||
if (null !== $featureAvailability) {
|
||||
$search->filterByFeatureAvId($featureAvailability, Criteria::IN);
|
||||
}
|
||||
|
||||
$excludeFeatureAvailable = $this->getExclude_feature_available();
|
||||
if ($excludeFeatureAvailable == true) {
|
||||
$excludeFeatureAvailability = $this->getExclude_feature_availability();
|
||||
if($excludeFeatureAvailability == true) {
|
||||
$search->filterByFeatureAvId(null, Criteria::NULL);
|
||||
}
|
||||
|
||||
$excludeDefaultValues = $this->getExclude_default_values();
|
||||
if ($excludeDefaultValues == true) {
|
||||
$excludeDefaultValues = $this->getExclude_personal_values();
|
||||
if($excludeDefaultValues == true) {
|
||||
$search->filterByByDefault(null, Criteria::NULL);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE);
|
||||
$search->addAscendingOrderByColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE');
|
||||
break;
|
||||
case "alpha-reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\Map\FeatureI18nTableMap::TITLE);
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE');
|
||||
break;
|
||||
case "manual":
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
@@ -120,17 +136,6 @@ class FeatureValue extends BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
/*$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);*/
|
||||
|
||||
$featureValues = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
@@ -138,14 +143,16 @@ class FeatureValue extends BaseLoop
|
||||
foreach ($featureValues as $featureValue) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $featureValue->getId());
|
||||
/*$loopResultRow->set("TITLE",$featureValue->getTitle());
|
||||
$loopResultRow->set("CHAPO", $featureValue->getChapo());
|
||||
$loopResultRow->set("DESCRIPTION", $featureValue->getDescription());
|
||||
$loopResultRow->set("POSTSCRIPTUM", $featureValue->getPostscriptum());*/
|
||||
|
||||
$loopResultRow->set("PERSONAL_VALUE", $featureValue->getByDefault())
|
||||
->set("TITLE",$featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE'))
|
||||
->set("CHAPO", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM'));
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,9 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
@@ -59,7 +62,7 @@ class Folder extends BaseLoop
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual-reverse', 'random'))
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'random'))
|
||||
),
|
||||
'manual'
|
||||
),
|
||||
@@ -76,7 +79,10 @@ class Folder extends BaseLoop
|
||||
{
|
||||
$search = FolderQuery::create();
|
||||
|
||||
$id = $this->getId();
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (!is_null($id)) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
@@ -88,7 +94,8 @@ class Folder extends BaseLoop
|
||||
$search->filterByParent($parent);
|
||||
}
|
||||
|
||||
$current = $this->getCurrent();
|
||||
|
||||
$current = $this->getCurrent();
|
||||
|
||||
if ($current === true) {
|
||||
$search->filterById($this->request->get("folder_id"));
|
||||
@@ -96,6 +103,7 @@ class Folder extends BaseLoop
|
||||
$search->filterById($this->request->get("folder_id"), Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
@@ -108,15 +116,15 @@ class Folder extends BaseLoop
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\FolderI18nTableMap::TITLE);
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha-reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\Map\FolderI18nTableMap::TITLE);
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual-reverse":
|
||||
case "manual_reverse":
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
case "manual":
|
||||
@@ -130,50 +138,44 @@ class Folder extends BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
/* perform search */
|
||||
$folders = $this->search($search, $pagination);
|
||||
|
||||
/* @todo */
|
||||
$notEmpty = $this->getNot_empty();
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
|
||||
if ($notEmpty && $folder->countAllProducts() == 0) continue;
|
||||
/*
|
||||
* no cause pagination lost :
|
||||
* if ($notEmpty && $folder->countAllProducts() == 0) continue;
|
||||
*/
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $folder->getId())
|
||||
->set("TITLE",$folder->getTitle())
|
||||
->set("CHAPO", $folder->getChapo())
|
||||
->set("DESCRIPTION", $folder->getDescription())
|
||||
->set("POSTSCRIPTUM", $folder->getPostscriptum())
|
||||
->set("PARENT", $folder->getParent())
|
||||
->set("CONTENT_COUNT", $folder->countChild())
|
||||
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $folder->getPosition())
|
||||
->set("ID", $folder->getId())
|
||||
->set("TITLE",$folder->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $folder->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $folder->getParent())
|
||||
->set("CONTENT_COUNT", $folder->countChild())
|
||||
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $folder->getPosition())
|
||||
|
||||
->set("CREATE_DATE", $folder->getCreatedAt())
|
||||
->set("UPDATE_DATE", $folder->getUpdatedAt())
|
||||
->set("VERSION", $folder->getVersion())
|
||||
->set("VERSION_DATE", $folder->getVersionCreatedAt())
|
||||
->set("VERSION_AUTHOR", $folder->getVersionCreatedBy())
|
||||
;
|
||||
->set("CREATE_DATE", $folder->getCreatedAt())
|
||||
->set("UPDATE_DATE", $folder->getUpdatedAt())
|
||||
->set("VERSION", $folder->getVersion())
|
||||
->set("VERSION_DATE", $folder->getVersionCreatedAt())
|
||||
->set("VERSION_AUTHOR", $folder->getVersionCreatedBy())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
0
core/lib/Thelia/Core/Template/Loop/Image.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/Image.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/Lang.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/Lang.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/Order.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/Order.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/OrderStatus.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Loop/OrderStatus.php
Normal file → Executable file
@@ -24,14 +24,21 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\Map\FeatureProductTableMap;
|
||||
use Thelia\Model\Map\ProductPriceTableMap;
|
||||
use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
use Thelia\Model\Map\ProductTableMap;
|
||||
use Thelia\Model\ProductCategoryQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
@@ -48,6 +55,8 @@ 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 BaseLoop
|
||||
{
|
||||
@@ -65,13 +74,13 @@ class Product extends BaseLoop
|
||||
)
|
||||
),
|
||||
Argument::createIntListTypeArgument('category'),
|
||||
//Argument::createBooleanTypeArgument('new'),
|
||||
//Argument::createBooleanTypeArgument('promo'),
|
||||
//Argument::createFloatTypeArgument('min_price'),
|
||||
//Argument::createFloatTypeArgument('max_price'),
|
||||
//Argument::createIntTypeArgument('min_stock'),
|
||||
//Argument::createFloatTypeArgument('min_weight'),
|
||||
//Argument::createFloatTypeArgument('max_weight'),
|
||||
Argument::createBooleanTypeArgument('new'),
|
||||
Argument::createBooleanTypeArgument('promo'),
|
||||
Argument::createFloatTypeArgument('min_price'),
|
||||
Argument::createFloatTypeArgument('max_price'),
|
||||
Argument::createIntTypeArgument('min_stock'),
|
||||
Argument::createFloatTypeArgument('min_weight'),
|
||||
Argument::createFloatTypeArgument('max_weight'),
|
||||
Argument::createBooleanTypeArgument('current'),
|
||||
Argument::createBooleanTypeArgument('current_category'),
|
||||
Argument::createIntTypeArgument('depth', 1),
|
||||
@@ -79,14 +88,14 @@ class Product extends BaseLoop
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha-reverse', /*'min_price', 'max_price',*/ 'manual', 'manual_reverse', 'ref', /*'promo', 'new',*/ 'random', 'given_id'))
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id'))
|
||||
),
|
||||
'alpha'
|
||||
),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
Argument::createIntListTypeArgument('exclude_category'),
|
||||
new Argument(
|
||||
'feature_available',
|
||||
'feature_availability',
|
||||
new TypeCollection(
|
||||
new Type\IntToCombinedIntsListType()
|
||||
)
|
||||
@@ -96,6 +105,24 @@ class Product extends BaseLoop
|
||||
new TypeCollection(
|
||||
new Type\IntToCombinedStringsListType()
|
||||
)
|
||||
),
|
||||
/*
|
||||
* promo, new, quantity, weight or price may differ depending on the different attributes
|
||||
* by default, product loop will look for at least 1 attribute which matches all the loop criteria : attribute_non_strict_match="none"
|
||||
* you can also provide a list of non-strict attributes.
|
||||
* ie : attribute_non_strict_match="promo,new"
|
||||
* loop will return the product if he has at least an attribute in promo and at least an attribute as new ; even if it's not the same attribute.
|
||||
* you can set all the attributes as non strict : attribute_non_strict_match="*"
|
||||
*
|
||||
* In order to allow such a process, we will have to make a LEFT JOIN foreach of the following case.
|
||||
*/
|
||||
new Argument(
|
||||
'attribute_non_strict_match',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('min_stock', 'promo', 'new', 'min_weight', 'max_weight', 'min_price', 'max_price')),
|
||||
new Type\EnumType(array('*', 'none'))
|
||||
),
|
||||
'none'
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -110,7 +137,12 @@ class Product extends BaseLoop
|
||||
{
|
||||
$search = ProductQuery::create();
|
||||
|
||||
//$search->withColumn('CASE WHEN ' . ProductTableMap::PROMO . '=1 THEN ' . ProductTableMap::PRICE2 . ' ELSE ' . ProductTableMap::PRICE . ' END', 'real_price');
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
||||
|
||||
$attributeNonStrictMatch = $this->getAttribute_non_strict_match();
|
||||
$isPSELeftJoinList = array();
|
||||
$isProductPriceLeftJoinList = array();
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -124,15 +156,15 @@ class Product extends BaseLoop
|
||||
$search->filterByRef($ref, Criteria::IN);
|
||||
}
|
||||
|
||||
$category = $this->getCategory();
|
||||
$category = $this->getCategory();
|
||||
|
||||
if (!is_null($category)) {
|
||||
$categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find();
|
||||
|
||||
$depth = $this->getDepth();
|
||||
|
||||
if (null !== $depth) {
|
||||
foreach (CategoryQuery::findAllChild($category, $depth) as $subCategory) {
|
||||
if(null !== $depth) {
|
||||
foreach(CategoryQuery::findAllChild($category, $depth) as $subCategory) {
|
||||
$categories->prepend($subCategory);
|
||||
}
|
||||
}
|
||||
@@ -143,79 +175,174 @@ class Product extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/*$new = $this->getNew();
|
||||
$new = $this->getNew();
|
||||
|
||||
if ($new === true) {
|
||||
$search->filterByNewness(1, Criteria::EQUAL);
|
||||
} elseif ($new === false) {
|
||||
$search->filterByNewness(0, Criteria::EQUAL);
|
||||
$isPSELeftJoinList[] = 'is_new';
|
||||
$search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN)
|
||||
->where('`is_new`.NEWNESS' . Criteria::EQUAL . '1')
|
||||
->where('NOT ISNULL(`is_new`.ID)');
|
||||
} else if($new === false) {
|
||||
$isPSELeftJoinList[] = 'is_new';
|
||||
$search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN)
|
||||
->where('`is_new`.NEWNESS' . Criteria::EQUAL . '0')
|
||||
->where('NOT ISNULL(`is_new`.ID)');
|
||||
}
|
||||
|
||||
$promo = $this->getPromo();
|
||||
|
||||
if ($promo === true) {
|
||||
$search->filterByPromo(1, Criteria::EQUAL);
|
||||
} elseif ($promo === false) {
|
||||
$search->filterByNewness(0, Criteria::EQUAL);
|
||||
$isPSELeftJoinList[] = 'is_promo';
|
||||
$search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN)
|
||||
->where('`is_promo`.PROMO' . Criteria::EQUAL . '1')
|
||||
->where('NOT ISNULL(`is_promo`.ID)');
|
||||
} else if($promo === false) {
|
||||
$isPSELeftJoinList[] = 'is_promo';
|
||||
$search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN)
|
||||
->where('`is_promo`.PROMO' . Criteria::EQUAL . '0')
|
||||
->where('NOT ISNULL(`is_promo`.ID)');
|
||||
}
|
||||
|
||||
$min_stock = $this->getMin_stock();
|
||||
|
||||
if (null != $min_stock) {
|
||||
$search->filterByQuantity($min_stock, Criteria::GREATER_EQUAL);
|
||||
$isPSELeftJoinList[] = 'is_min_stock';
|
||||
$search->joinProductSaleElements('is_min_stock', Criteria::LEFT_JOIN)
|
||||
->where('`is_min_stock`.QUANTITY' . Criteria::GREATER_THAN . '?', $min_stock, \PDO::PARAM_INT)
|
||||
->where('NOT ISNULL(`is_min_stock`.ID)');
|
||||
}
|
||||
|
||||
$min_price = $this->getMin_price();*/
|
||||
$min_weight = $this->getMin_weight();
|
||||
|
||||
//if (null !== $min_price) {
|
||||
/**
|
||||
* Following should work but does not :
|
||||
*
|
||||
* $search->filterBy('real_price', $max_price, Criteria::GREATER_EQUAL);
|
||||
*/
|
||||
/*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1')
|
||||
->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1')
|
||||
->condition('min_price2', ProductTableMap::PRICE2 . Criteria::GREATER_EQUAL . '?', $min_price)
|
||||
->condition('min_price', ProductTableMap::PRICE . Criteria::GREATER_EQUAL . '?', $min_price)
|
||||
->combine(array('in_promo', 'min_price2'), 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) {
|
||||
/**
|
||||
* Following should work but does not :
|
||||
*
|
||||
* $search->filterBy('real_price', $max_price, Criteria::LESS_EQUAL);
|
||||
*/
|
||||
/*$search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1')
|
||||
->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1')
|
||||
->condition('max_price2', ProductTableMap::PRICE2 . Criteria::LESS_EQUAL . '?', $max_price)
|
||||
->condition('max_price', ProductTableMap::PRICE . Criteria::LESS_EQUAL . '?', $max_price)
|
||||
->combine(array('in_promo', 'max_price2'), 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);
|
||||
}*/
|
||||
|
||||
/*$min_weight = $this->getMin_weight();
|
||||
|
||||
if (null !== $min_weight) {
|
||||
$search->filterByWeight($min_weight, Criteria::GREATER_EQUAL);
|
||||
if (null != $min_weight) {
|
||||
$isPSELeftJoinList[] = 'is_min_weight';
|
||||
$search->joinProductSaleElements('is_min_weight', Criteria::LEFT_JOIN)
|
||||
->where('`is_min_weight`.WEIGHT' . Criteria::GREATER_THAN . '?', $min_weight, \PDO::PARAM_STR)
|
||||
->where('NOT ISNULL(`is_min_weight`.ID)');
|
||||
}
|
||||
|
||||
$max_weight = $this->getMax_weight();
|
||||
|
||||
if (null !== $max_weight) {
|
||||
$search->filterByWeight($max_weight, Criteria::LESS_EQUAL);
|
||||
}*/
|
||||
if (null != $max_weight) {
|
||||
$isPSELeftJoinList[] = 'is_max_weight';
|
||||
$search->joinProductSaleElements('is_max_weight', Criteria::LEFT_JOIN)
|
||||
->where('`is_max_weight`.WEIGHT' . Criteria::LESS_THAN . '?', $max_weight, \PDO::PARAM_STR)
|
||||
->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;
|
||||
} else {
|
||||
$actuallyUsedAttributeNonStrictMatchList = array_values(array_intersect($isPSELeftJoinList, $attributeNonStrictMatch));
|
||||
}
|
||||
|
||||
foreach($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) {
|
||||
if($key == 0)
|
||||
continue;
|
||||
$search->where('`' . $actuallyUsedAttributeNonStrictMatch . '`.ID=' . '`' . $actuallyUsedAttributeNonStrictMatchList[$key-1] . '`.ID');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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(count($isPSELeftJoinList) == 0) {
|
||||
$joiningTable = "global";
|
||||
$isPSELeftJoinList[] = $joiningTable;
|
||||
$search->joinProductSaleElements('global', Criteria::LEFT_JOIN);
|
||||
} else {
|
||||
$joiningTable = $isPSELeftJoinList[0];
|
||||
}
|
||||
|
||||
$isProductPriceLeftJoinList[$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);
|
||||
|
||||
$search->addJoinObject($minPriceJoin);
|
||||
}
|
||||
|
||||
/*
|
||||
* we need to test all promo field from our previous conditions. Indeed ie:
|
||||
* product P0, attributes color : red
|
||||
* P0red is in promo and is the only attribute combinaton availability.
|
||||
* so the product might be consider as in promo (in outputs and ordering)
|
||||
* We got the following loop to display in promo AND new product but we don't care it's the same attribute which is new and in promo :
|
||||
* {loop type="product" promo="1" new="1" attribute_non_strict_match="promo,new"} {/loop}
|
||||
* our request will so far returns 1 line
|
||||
*
|
||||
* is_promo.ID | is_promo.PROMO | is_promo.NEWNESS | is_new.ID | is_new.PROMO | is_new.NEWNESS
|
||||
* NULL NULL NULL red_id 1 0
|
||||
*
|
||||
* So that we can say the product is in global promo only with is_promo.PROMO, we must acknowledge it with (is_promo.PROMO OR is_new.PROMO)
|
||||
*/
|
||||
$booleanMatchedPromoList = array();
|
||||
$booleanMatchedNewnessList = array();
|
||||
foreach($isPSELeftJoinList as $isPSELeftJoin) {
|
||||
$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('MAX(' . implode(' OR ', $booleanMatchedPromoList) . ')', 'main_product_is_promo');
|
||||
$search->withColumn('MAX(' . implode(' OR ', $booleanMatchedNewnessList) . ')', 'main_product_is_new');
|
||||
$search->withColumn('MAX(' . implode(' OR ', $booleanMatchedPriceList) . ')', 'real_highest_price');
|
||||
$search->withColumn('MIN(' . implode(' OR ', $booleanMatchedPriceList) . ')', 'real_lowest_price');
|
||||
|
||||
|
||||
$current = $this->getCurrent();
|
||||
|
||||
if ($current === true) {
|
||||
$search->filterById($this->request->get("product_id"));
|
||||
} elseif ($current === false) {
|
||||
} elseif($current === false) {
|
||||
$search->filterById($this->request->get("product_id"), Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
@@ -232,7 +359,7 @@ class Product extends BaseLoop
|
||||
)->find(),
|
||||
Criteria::IN
|
||||
);
|
||||
} elseif ($current_category === false) {
|
||||
} elseif($current_category === false) {
|
||||
$search->filterByCategory(
|
||||
CategoryQuery::create()->filterByProduct(
|
||||
ProductCategoryQuery::create()->filterByProductId(
|
||||
@@ -249,57 +376,6 @@ class Product extends BaseLoop
|
||||
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE);
|
||||
break;
|
||||
case "alpha-reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE);
|
||||
break;
|
||||
/*case "min_price":
|
||||
$search->orderBy('real_price', Criteria::ASC);
|
||||
break;
|
||||
case "max_price":
|
||||
$search->orderBy('real_price', Criteria::DESC);
|
||||
break;*/
|
||||
case "manual":
|
||||
if(null === $category || count($category) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "manual_reverse":
|
||||
if(null === $category || count($category) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
case "ref":
|
||||
$search->orderByRef(Criteria::ASC);
|
||||
break;
|
||||
/*case "promo":
|
||||
$search->orderByPromo(Criteria::DESC);
|
||||
break;
|
||||
case "new":
|
||||
$search->orderByNewness(Criteria::DESC);
|
||||
break;*/
|
||||
case "given_id":
|
||||
if(null === $id)
|
||||
throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument');
|
||||
foreach ($id as $singleId) {
|
||||
$givenIdMatched = 'given_id_matched_' . $singleId;
|
||||
$search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched);
|
||||
$search->orderBy($givenIdMatched, Criteria::DESC);
|
||||
}
|
||||
break;
|
||||
case "random":
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
break(2);
|
||||
}
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
@@ -315,11 +391,11 @@ class Product extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
$feature_available = $this->getFeature_available();
|
||||
$feature_availability = $this->getFeature_availability();
|
||||
|
||||
if (null !== $feature_available) {
|
||||
foreach ($feature_available as $feature => $feature_choice) {
|
||||
foreach ($feature_choice['values'] as $feature_av) {
|
||||
if(null !== $feature_availability) {
|
||||
foreach($feature_availability as $feature => $feature_choice) {
|
||||
foreach($feature_choice['values'] as $feature_av) {
|
||||
$featureAlias = 'fa_' . $feature;
|
||||
if($feature_av != '*')
|
||||
$featureAlias .= '_' . $feature_av;
|
||||
@@ -331,7 +407,7 @@ class Product extends BaseLoop
|
||||
|
||||
/* format for mysql */
|
||||
$sqlWhereString = $feature_choice['expression'];
|
||||
if ($sqlWhereString == '*') {
|
||||
if($sqlWhereString == '*') {
|
||||
$sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)';
|
||||
} else {
|
||||
$sqlWhereString = preg_replace('#([0-9]+)#', 'NOT ISNULL(`fa_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
|
||||
@@ -345,9 +421,9 @@ class Product extends BaseLoop
|
||||
|
||||
$feature_values = $this->getFeature_values();
|
||||
|
||||
if (null !== $feature_values) {
|
||||
foreach ($feature_values as $feature => $feature_choice) {
|
||||
foreach ($feature_choice['values'] as $feature_value) {
|
||||
if(null !== $feature_values) {
|
||||
foreach($feature_values as $feature => $feature_choice) {
|
||||
foreach($feature_choice['values'] as $feature_value) {
|
||||
$featureAlias = 'fv_' . $feature;
|
||||
if($feature_value != '*')
|
||||
$featureAlias .= '_' . $feature_value;
|
||||
@@ -359,7 +435,7 @@ class Product extends BaseLoop
|
||||
|
||||
/* format for mysql */
|
||||
$sqlWhereString = $feature_choice['expression'];
|
||||
if ($sqlWhereString == '*') {
|
||||
if($sqlWhereString == '*') {
|
||||
$sqlWhereString = 'NOT ISNULL(`fv_' . $feature . '`.ID)';
|
||||
} else {
|
||||
$sqlWhereString = preg_replace('#([a-zA-Z0-9_\-]+)#', 'NOT ISNULL(`fv_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
|
||||
@@ -371,19 +447,60 @@ class Product extends BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
$search->groupBy(ProductTableMap::ID);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "min_price":
|
||||
$search->addAscendingOrderByColumn('real_lowest_price', Criteria::ASC);
|
||||
break;
|
||||
case "max_price":
|
||||
$search->addDescendingOrderByColumn('real_lowest_price');
|
||||
break;
|
||||
case "manual":
|
||||
if(null === $category || count($category) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "manual_reverse":
|
||||
if(null === $category || count($category) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
case "ref":
|
||||
$search->orderByRef(Criteria::ASC);
|
||||
break;
|
||||
case "promo":
|
||||
$search->addDescendingOrderByColumn('main_product_is_promo');
|
||||
break;
|
||||
case "new":
|
||||
$search->addDescendingOrderByColumn('main_product_is_new');
|
||||
break;
|
||||
case "given_id":
|
||||
if(null === $id)
|
||||
throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument');
|
||||
foreach($id as $singleId) {
|
||||
$givenIdMatched = 'given_id_matched_' . $singleId;
|
||||
$search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched);
|
||||
$search->orderBy($givenIdMatched, Criteria::DESC);
|
||||
}
|
||||
break;
|
||||
case "random":
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
break(2);
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$products = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
@@ -393,15 +510,13 @@ class Product extends BaseLoop
|
||||
|
||||
$loopResultRow->set("ID", $product->getId())
|
||||
->set("REF",$product->getRef())
|
||||
->set("TITLE",$product->getTitle())
|
||||
->set("CHAPO", $product->getChapo())
|
||||
->set("DESCRIPTION", $product->getDescription())
|
||||
->set("POSTSCRIPTUM", $product->getPostscriptum())
|
||||
//->set("PRICE", $product->getPrice())
|
||||
//->set("PROMO_PRICE", $product->getPrice2())
|
||||
//->set("WEIGHT", $product->getWeight())
|
||||
//->set("PROMO", $product->getPromo())
|
||||
//->set("NEW", $product->getNewness())
|
||||
->set("TITLE",$product->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("BEST_PRICE", $product->getVirtualColumn('real_lowest_price'))
|
||||
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION", $product->getPosition())
|
||||
;
|
||||
|
||||
@@ -410,5 +525,4 @@ class Product extends BaseLoop
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
140
core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php
Executable file
140
core/lib/Thelia/Core/Template/Loop/ProductSaleElement.php
Executable file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* Product Sale Elements loop
|
||||
*
|
||||
* @todo : manage currency and attribute_availability
|
||||
*
|
||||
* Class ProductSaleElements
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class ProductSaleElements extends BaseLoop
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('currency'),
|
||||
Argument::createIntTypeArgument('product', null, true),
|
||||
new Argument(
|
||||
'attribute_availability',
|
||||
new TypeCollection(
|
||||
new Type\IntToCombinedIntsListType()
|
||||
)
|
||||
),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'attribute', 'attribute_reverse'))
|
||||
),
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = ProductSaleElementsQuery::create();
|
||||
|
||||
$product = $this->getProduct();
|
||||
|
||||
$search->filterByProductId($product, Criteria::EQUAL);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
//$search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE);
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
//$search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE);
|
||||
break;
|
||||
case "attribute":
|
||||
//$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "attribute_reverse":
|
||||
//$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$currency = $this->getCurrency();
|
||||
|
||||
$search->joinProductPrice('price', Criteria::INNER_JOIN);
|
||||
//->addJoinCondition('price', '');
|
||||
|
||||
$search->withColumn('`price`.CURRENCY_ID', 'price_CURRENCY_ID')
|
||||
->withColumn('`price`.PRICE', 'price_PRICE')
|
||||
->withColumn('`price`.PROMO_PRICE', 'price_PROMO_PRICE');
|
||||
|
||||
$PSEValues = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($PSEValues as $PSEValue) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow->set("ID", $PSEValue->getId())
|
||||
->set("QUANTITY", $PSEValue->getQuantity())
|
||||
->set("IS_PROMO", $PSEValue->getPromo() === 1 ? 1 : 0)
|
||||
->set("IS_NEW", $PSEValue->getNewness() === 1 ? 1 : 0)
|
||||
->set("WEIGHT", $PSEValue->getWeight())
|
||||
|
||||
->set("CURRENCY", $PSEValue->getVirtualColumn('price_CURRENCY_ID'))
|
||||
->set("PRICE", $PSEValue->getVirtualColumn('price_PRICE'))
|
||||
->set("PROMO_PRICE", $PSEValue->getVirtualColumn('price_PROMO_PRICE'));
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CustomerTitleQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
@@ -64,35 +66,28 @@ class Title extends BaseLoop
|
||||
{
|
||||
$search = CustomerTitleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('SHORT', 'LONG'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
$search->orderByPosition();
|
||||
|
||||
/* perform search */
|
||||
$titles = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($titles as $title) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $title->getId());
|
||||
$loopResultRow->set("DEFAULT", $title->getByDefault());
|
||||
$loopResultRow->set("SHORT", $title->getShort());
|
||||
$loopResultRow->set("LONG", $title->getLong());
|
||||
$loopResultRow->set("ID", $title->getId())
|
||||
->set("DEFAULT", $title->getByDefault())
|
||||
->set("SHORT", $title->getVirtualColumn('i18n_SHORT'))
|
||||
->set("LONG", $title->getVirtualColumn('i18n_LONG'));
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
0
core/lib/Thelia/Core/Template/ParserContext.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/ParserContext.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
Normal file → Executable file
@@ -61,7 +61,7 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
*/
|
||||
public static function getPagination($loopId)
|
||||
{
|
||||
if (!empty(self::$pagination[$loopId])) {
|
||||
if(!empty(self::$pagination[$loopId])) {
|
||||
return self::$pagination[$loopId];
|
||||
} else {
|
||||
return null;
|
||||
@@ -75,8 +75,9 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
{
|
||||
$type = $this->getParam($params, 'type');
|
||||
|
||||
if (null == $type)
|
||||
if (null == $type) {
|
||||
throw new \InvalidArgumentException("Missing 'type' parameter in count arguments");
|
||||
}
|
||||
|
||||
$loop = $this->createLoopInstance($params);
|
||||
|
||||
@@ -101,13 +102,15 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
{
|
||||
$name = $this->getParam($params, 'name');
|
||||
|
||||
if (null == $name)
|
||||
if (null == $name) {
|
||||
throw new \InvalidArgumentException("Missing 'name' parameter in loop arguments");
|
||||
}
|
||||
|
||||
$type = $this->getParam($params, 'type');
|
||||
|
||||
if (null == $type)
|
||||
if (null == $type) {
|
||||
throw new \InvalidArgumentException("Missing 'type' parameter in loop arguments");
|
||||
}
|
||||
|
||||
if ($content === null) {
|
||||
// Check if a loop with the same name exists in the current scope, and abort if it's the case.
|
||||
|
||||
0
core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php
Normal file → Executable file
0
core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php
Normal file → Executable file
0
core/lib/Thelia/Core/Translation/Translator.php
Normal file → Executable file
0
core/lib/Thelia/Core/Translation/Translator.php
Normal file → Executable file
0
core/lib/Thelia/Exception/ImageException.php
Normal file → Executable file
0
core/lib/Thelia/Exception/ImageException.php
Normal file → Executable file
0
core/lib/Thelia/Exception/InvalidCartException.php
Normal file → Executable file
0
core/lib/Thelia/Exception/InvalidCartException.php
Normal file → Executable file
0
core/lib/Thelia/Form/CartAdd.php
Normal file → Executable file
0
core/lib/Thelia/Form/CartAdd.php
Normal file → Executable file
0
core/lib/Thelia/Form/CategoryCreationForm.php
Normal file → Executable file
0
core/lib/Thelia/Form/CategoryCreationForm.php
Normal file → Executable file
0
core/lib/Thelia/Form/CategoryDeletionForm.php
Normal file → Executable file
0
core/lib/Thelia/Form/CategoryDeletionForm.php
Normal file → Executable file
0
core/lib/Thelia/Form/CustomerLogin.php
Normal file → Executable file
0
core/lib/Thelia/Form/CustomerLogin.php
Normal file → Executable file
0
core/lib/Thelia/Form/Exception/FormValidationException.php
Normal file → Executable file
0
core/lib/Thelia/Form/Exception/FormValidationException.php
Normal file → Executable file
0
core/lib/Thelia/Form/Exception/ProductNotFoundException.php
Normal file → Executable file
0
core/lib/Thelia/Form/Exception/ProductNotFoundException.php
Normal file → Executable file
0
core/lib/Thelia/Form/Exception/StockNotFoundException.php
Normal file → Executable file
0
core/lib/Thelia/Form/Exception/StockNotFoundException.php
Normal file → Executable file
15
core/lib/Thelia/Model/Base/Accessory.php
Normal file → Executable file
15
core/lib/Thelia/Model/Base/Accessory.php
Normal file → Executable file
@@ -266,7 +266,7 @@ abstract class Accessory implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -891,6 +891,10 @@ abstract class Accessory implements ActiveRecordInterface
|
||||
$modifiedColumns = array();
|
||||
$index = 0;
|
||||
|
||||
$this->modifiedColumns[] = AccessoryTableMap::ID;
|
||||
if (null !== $this->id) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key (' . AccessoryTableMap::ID . ')');
|
||||
}
|
||||
|
||||
// check the columns in natural order for more readable SQL queries
|
||||
if ($this->isColumnModified(AccessoryTableMap::ID)) {
|
||||
@@ -948,6 +952,13 @@ abstract class Accessory 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);
|
||||
}
|
||||
|
||||
@@ -1224,7 +1235,6 @@ abstract class Accessory implements ActiveRecordInterface
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
|
||||
{
|
||||
$copyObj->setId($this->getId());
|
||||
$copyObj->setProductId($this->getProductId());
|
||||
$copyObj->setAccessory($this->getAccessory());
|
||||
$copyObj->setPosition($this->getPosition());
|
||||
@@ -1232,6 +1242,7 @@ abstract class Accessory 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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
0
core/lib/Thelia/Model/Base/AccessoryQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AccessoryQuery.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/Address.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/Address.php
Normal file → Executable file
@@ -388,7 +388,7 @@ abstract class Address implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
0
core/lib/Thelia/Model/Base/AddressQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AddressQuery.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/Admin.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/Admin.php
Normal file → Executable file
@@ -300,7 +300,7 @@ abstract class Admin implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
2
core/lib/Thelia/Model/Base/AdminGroup.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/AdminGroup.php
Normal file → Executable file
@@ -262,7 +262,7 @@ abstract class AdminGroup implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
0
core/lib/Thelia/Model/Base/AdminGroupQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AdminGroupQuery.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/AdminLog.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/AdminLog.php
Normal file → Executable file
@@ -266,7 +266,7 @@ abstract class AdminLog implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
0
core/lib/Thelia/Model/Base/AdminLogQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AdminLogQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AdminQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AdminQuery.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/Area.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/Area.php
Normal file → Executable file
@@ -277,7 +277,7 @@ abstract class Area implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
0
core/lib/Thelia/Model/Base/AreaQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AreaQuery.php
Normal file → Executable file
12
core/lib/Thelia/Model/Base/Attribute.php
Normal file → Executable file
12
core/lib/Thelia/Model/Base/Attribute.php
Normal file → Executable file
@@ -132,7 +132,7 @@ abstract class Attribute implements ActiveRecordInterface
|
||||
* Current locale
|
||||
* @var string
|
||||
*/
|
||||
protected $currentLocale = 'en_US';
|
||||
protected $currentLocale = 'en_EN';
|
||||
|
||||
/**
|
||||
* Current translation objects
|
||||
@@ -326,7 +326,7 @@ abstract class Attribute implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2554,7 +2554,7 @@ abstract class Attribute implements ActiveRecordInterface
|
||||
} // if ($deep)
|
||||
|
||||
// i18n behavior
|
||||
$this->currentLocale = 'en_US';
|
||||
$this->currentLocale = 'en_EN';
|
||||
$this->currentTranslations = null;
|
||||
|
||||
if ($this->collAttributeAvs instanceof Collection) {
|
||||
@@ -2612,7 +2612,7 @@ abstract class Attribute implements ActiveRecordInterface
|
||||
*
|
||||
* @return ChildAttribute The current object (for fluent API support)
|
||||
*/
|
||||
public function setLocale($locale = 'en_US')
|
||||
public function setLocale($locale = 'en_EN')
|
||||
{
|
||||
$this->currentLocale = $locale;
|
||||
|
||||
@@ -2636,7 +2636,7 @@ abstract class Attribute implements ActiveRecordInterface
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildAttributeI18n */
|
||||
public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
|
||||
public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
|
||||
{
|
||||
if (!isset($this->currentTranslations[$locale])) {
|
||||
if (null !== $this->collAttributeI18ns) {
|
||||
@@ -2671,7 +2671,7 @@ abstract class Attribute implements ActiveRecordInterface
|
||||
*
|
||||
* @return ChildAttribute The current object (for fluent API support)
|
||||
*/
|
||||
public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null)
|
||||
public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
|
||||
{
|
||||
if (!$this->isNew()) {
|
||||
ChildAttributeI18nQuery::create()
|
||||
|
||||
12
core/lib/Thelia/Model/Base/AttributeAv.php
Normal file → Executable file
12
core/lib/Thelia/Model/Base/AttributeAv.php
Normal file → Executable file
@@ -122,7 +122,7 @@ abstract class AttributeAv implements ActiveRecordInterface
|
||||
* Current locale
|
||||
* @var string
|
||||
*/
|
||||
protected $currentLocale = 'en_US';
|
||||
protected $currentLocale = 'en_EN';
|
||||
|
||||
/**
|
||||
* Current translation objects
|
||||
@@ -298,7 +298,7 @@ abstract class AttributeAv implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1903,7 +1903,7 @@ abstract class AttributeAv implements ActiveRecordInterface
|
||||
} // if ($deep)
|
||||
|
||||
// i18n behavior
|
||||
$this->currentLocale = 'en_US';
|
||||
$this->currentLocale = 'en_EN';
|
||||
$this->currentTranslations = null;
|
||||
|
||||
if ($this->collAttributeCombinations instanceof Collection) {
|
||||
@@ -1950,7 +1950,7 @@ abstract class AttributeAv implements ActiveRecordInterface
|
||||
*
|
||||
* @return ChildAttributeAv The current object (for fluent API support)
|
||||
*/
|
||||
public function setLocale($locale = 'en_US')
|
||||
public function setLocale($locale = 'en_EN')
|
||||
{
|
||||
$this->currentLocale = $locale;
|
||||
|
||||
@@ -1974,7 +1974,7 @@ abstract class AttributeAv implements ActiveRecordInterface
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildAttributeAvI18n */
|
||||
public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
|
||||
public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
|
||||
{
|
||||
if (!isset($this->currentTranslations[$locale])) {
|
||||
if (null !== $this->collAttributeAvI18ns) {
|
||||
@@ -2009,7 +2009,7 @@ abstract class AttributeAv implements ActiveRecordInterface
|
||||
*
|
||||
* @return ChildAttributeAv The current object (for fluent API support)
|
||||
*/
|
||||
public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null)
|
||||
public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
|
||||
{
|
||||
if (!$this->isNew()) {
|
||||
ChildAttributeAvI18nQuery::create()
|
||||
|
||||
8
core/lib/Thelia/Model/Base/AttributeAvI18n.php
Normal file → Executable file
8
core/lib/Thelia/Model/Base/AttributeAvI18n.php
Normal file → Executable file
@@ -61,7 +61,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface
|
||||
|
||||
/**
|
||||
* The value for the locale field.
|
||||
* Note: this column has a database default value of: 'en_US'
|
||||
* Note: this column has a database default value of: 'en_EN'
|
||||
* @var string
|
||||
*/
|
||||
protected $locale;
|
||||
@@ -111,7 +111,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface
|
||||
*/
|
||||
public function applyDefaultValues()
|
||||
{
|
||||
$this->locale = 'en_US';
|
||||
$this->locale = 'en_EN';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,7 +272,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -576,7 +576,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasOnlyDefaultValues()
|
||||
{
|
||||
if ($this->locale !== 'en_US') {
|
||||
if ($this->locale !== 'en_EN') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
0
core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php
Normal file → Executable file
6
core/lib/Thelia/Model/Base/AttributeAvQuery.php
Normal file → Executable file
6
core/lib/Thelia/Model/Base/AttributeAvQuery.php
Normal file → Executable file
@@ -841,7 +841,7 @@ abstract class AttributeAvQuery extends ModelCriteria
|
||||
*
|
||||
* @return ChildAttributeAvQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$relationName = $relationAlias ? $relationAlias : 'AttributeAvI18n';
|
||||
|
||||
@@ -859,7 +859,7 @@ abstract class AttributeAvQuery extends ModelCriteria
|
||||
*
|
||||
* @return ChildAttributeAvQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN)
|
||||
public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$this
|
||||
->joinI18n($locale, null, $joinType)
|
||||
@@ -880,7 +880,7 @@ abstract class AttributeAvQuery extends ModelCriteria
|
||||
*
|
||||
* @return ChildAttributeAvI18nQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinI18n($locale, $relationAlias, $joinType)
|
||||
|
||||
2
core/lib/Thelia/Model/Base/AttributeCategory.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/AttributeCategory.php
Normal file → Executable file
@@ -262,7 +262,7 @@ abstract class AttributeCategory implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
0
core/lib/Thelia/Model/Base/AttributeCategoryQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AttributeCategoryQuery.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/AttributeCombination.php
Normal file → Executable file
2
core/lib/Thelia/Model/Base/AttributeCombination.php
Normal file → Executable file
@@ -269,7 +269,7 @@ abstract class AttributeCombination implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
0
core/lib/Thelia/Model/Base/AttributeCombinationQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AttributeCombinationQuery.php
Normal file → Executable file
8
core/lib/Thelia/Model/Base/AttributeI18n.php
Normal file → Executable file
8
core/lib/Thelia/Model/Base/AttributeI18n.php
Normal file → Executable file
@@ -61,7 +61,7 @@ abstract class AttributeI18n implements ActiveRecordInterface
|
||||
|
||||
/**
|
||||
* The value for the locale field.
|
||||
* Note: this column has a database default value of: 'en_US'
|
||||
* Note: this column has a database default value of: 'en_EN'
|
||||
* @var string
|
||||
*/
|
||||
protected $locale;
|
||||
@@ -111,7 +111,7 @@ abstract class AttributeI18n implements ActiveRecordInterface
|
||||
*/
|
||||
public function applyDefaultValues()
|
||||
{
|
||||
$this->locale = 'en_US';
|
||||
$this->locale = 'en_EN';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,7 +272,7 @@ abstract class AttributeI18n implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasVirtualColumn($name)
|
||||
{
|
||||
return isset($this->virtualColumns[$name]);
|
||||
return array_key_exists($name, $this->virtualColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -576,7 +576,7 @@ abstract class AttributeI18n implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasOnlyDefaultValues()
|
||||
{
|
||||
if ($this->locale !== 'en_US') {
|
||||
if ($this->locale !== 'en_EN') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
0
core/lib/Thelia/Model/Base/AttributeI18nQuery.php
Normal file → Executable file
0
core/lib/Thelia/Model/Base/AttributeI18nQuery.php
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user