diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 58c0c8579..b5ccb598c 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -9,11 +9,13 @@ + + diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 87ea0ec08..009ed1ed1 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -161,11 +161,13 @@ class Category extends BaseLoop $categories = $this->search($search, $pagination); + $notEmpty = $this->getNot_empty(); + $loopResult = new LoopResult(); foreach ($categories as $category) { - if ($this->not_empty && $category->countAllProducts() == 0) continue; + if ($notEmpty && $category->countAllProducts() == 0) continue; $loopResultRow = new LoopResultRow(); diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php new file mode 100755 index 000000000..f0606755d --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -0,0 +1,238 @@ +. */ +/* */ +/*************************************************************************************/ + +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\FeatureContentQuery; +use Thelia\Model\FolderQuery; +use Thelia\Model\Map\ContentTableMap; +use Thelia\Model\ContentFolderQuery; +use Thelia\Model\ContentQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * + * Content loop + * + * + * Class Content + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Content extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('folder'), + Argument::createBooleanTypeArgument('current'), + Argument::createBooleanTypeArgument('current_folder'), + Argument::createIntTypeArgument('depth', 1), + Argument::createBooleanTypeArgument('visible', 1), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'random', 'given_id')) + ), + 'alpha' + ), + Argument::createIntListTypeArgument('exclude'), + Argument::createIntListTypeArgument('exclude_folder') + ); + } + + /** + * @param $pagination + * + * @return LoopResult + * @throws \InvalidArgumentException + */ + public function exec(&$pagination) + { + $search = ContentQuery::create(); + + $id = $this->getId(); + + if (!is_null($id)) { + $search->filterById($id, Criteria::IN); + } + + $folder = $this->getFolder(); + + if (!is_null($folder)) { + $folders = FolderQuery::create()->filterById($folder, Criteria::IN)->find(); + + $depth = $this->getDepth(); + + if(null !== $depth) { + foreach(FolderQuery::findAllChild($folder, $depth) as $subFolder) { + $folders->prepend($subFolder); + } + } + + $search->filterByFolder( + $folders, + Criteria::IN + ); + } + + $current = $this->getCurrent(); + + if ($current === true) { + $search->filterById($this->request->get("content_id")); + } elseif($current === false) { + $search->filterById($this->request->get("content_id"), Criteria::NOT_IN); + } + + $current_folder = $this->getCurrent_folder(); + + if ($current_folder === true) { + $search->filterByFolder( + FolderQuery::create()->filterByContent( + ContentFolderQuery::create()->filterByContentId( + $this->request->get("content_id"), + Criteria::EQUAL + )->find(), + Criteria::IN + )->find(), + Criteria::IN + ); + } elseif($current_folder === false) { + $search->filterByFolder( + FolderQuery::create()->filterByContent( + ContentFolderQuery::create()->filterByContentId( + $this->request->get("content_id"), + Criteria::EQUAL + )->find(), + Criteria::IN + )->find(), + Criteria::NOT_IN + ); + } + + $visible = $this->getVisible(); + + $search->filterByVisible($visible); + + $orders = $this->getOrder(); + + foreach($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn(\Thelia\Model\Map\ContentI18nTableMap::TITLE); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn(\Thelia\Model\Map\ContentI18nTableMap::TITLE); + break; + case "manual": + if(null === $folder || count($folder) != 1) + throw new \InvalidArgumentException('Manual order cannot be set without single folder argument'); + $search->orderByPosition(Criteria::ASC); + break; + case "manual_reverse": + if(null === $folder || count($folder) != 1) + throw new \InvalidArgumentException('Manual order cannot be set without single folder argument'); + $search->orderByPosition(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(ContentTableMap::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)) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $exclude_folder = $this->getExclude_folder(); + + if (!is_null($exclude_folder)) { + $search->filterByFolder( + FolderQuery::create()->filterById($exclude_folder, Criteria::IN)->find(), + 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->groupBy(ContentTableMap::ID); + + $contents = $this->search($search, $pagination); + + $loopResult = new LoopResult(); + + foreach ($contents as $content) { + $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("POSITION", $content->getPosition()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } + +} diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php new file mode 100755 index 000000000..b6b5768fd --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -0,0 +1,179 @@ +. */ +/* */ +/*************************************************************************************/ + +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\Log\Tlog; + +use Thelia\Model\FolderQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * Class Folder + * + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Folder extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntTypeArgument('parent'), + Argument::createBooleanTypeArgument('current'), + Argument::createBooleanTypeArgument('not_empty', 0), + Argument::createBooleanTypeArgument('visible', 1), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual-reverse', 'random')) + ), + 'manual' + ), + Argument::createIntListTypeArgument('exclude') + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = FolderQuery::create(); + + $id = $this->getId(); + + if (!is_null($id)) { + $search->filterById($id, Criteria::IN); + } + + $parent = $this->getParent(); + + if (!is_null($parent)) { + $search->filterByParent($parent); + } + + + $current = $this->getCurrent(); + + if ($current === true) { + $search->filterById($this->request->get("folder_id")); + } elseif ($current === false) { + $search->filterById($this->request->get("folder_id"), Criteria::NOT_IN); + } + + + $exclude = $this->getExclude(); + + if (!is_null($exclude)) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $search->filterByVisible($this->getVisible() ? 1 : 0); + + $orders = $this->getOrder(); + + foreach($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn(\Thelia\Model\Map\FolderI18nTableMap::TITLE); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn(\Thelia\Model\Map\FolderI18nTableMap::TITLE); + break; + case "manual-reverse": + $search->orderByPosition(Criteria::DESC); + break; + case "manual": + $search->orderByPosition(Criteria::ASC); + break; + case "random": + $search->clearOrderByColumns(); + $search->addAscendingOrderByColumn('RAND()'); + break(2); + break; + } + } + + /** + * \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 + ); + + $folders = $this->search($search, $pagination); + + $notEmpty = $this->getNot_empty(); + + $loopResult = new LoopResult(); + + foreach ($folders as $folder) { + + 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("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; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 817419ff4..d50bfc495 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -109,6 +109,7 @@ class Product extends BaseLoop * @param $pagination * * @return \Thelia\Core\Template\Element\LoopResult + * @throws \InvalidArgumentException */ public function exec(&$pagination) { @@ -402,11 +403,11 @@ class Product extends BaseLoop ->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("PRICE", $product->getPrice()) + //->set("PROMO_PRICE", $product->getPrice2()) + //->set("WEIGHT", $product->getWeight()) + //->set("PROMO", $product->getPromo()) + //->set("NEW", $product->getNewness()) ->set("POSITION", $product->getPosition()) ; diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index b23f5998d..a19ab6796 100755 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -4,6 +4,37 @@ namespace Thelia\Model; use Thelia\Model\Base\Folder as BaseFolder; -class Folder extends BaseFolder { +class Folder extends BaseFolder +{ + /** + * @return int number of contents for the folder + */ + public function countChild() + { + return FolderQuery::countChild($this->getId()); + } + /** + * + * count all products for current category and sub categories + * + * @return int + */ + public function countAllContents() + { + $children = FolderQuery::findAllChild($this->getId()); + array_push($children, $this); + + $contentsCount = 0; + + foreach($children as $child) + { + $contentsCount += ProductQuery::create() + ->filterByCategory($child) + ->count(); + } + + return $contentsCount; + + } } diff --git a/core/lib/Thelia/Model/FolderQuery.php b/core/lib/Thelia/Model/FolderQuery.php index 388dff085..949cbbc43 100755 --- a/core/lib/Thelia/Model/FolderQuery.php +++ b/core/lib/Thelia/Model/FolderQuery.php @@ -15,6 +15,52 @@ use Thelia\Model\Base\FolderQuery as BaseFolderQuery; * long as it does not already exist in the output directory. * */ -class FolderQuery extends BaseFolderQuery { +class FolderQuery extends BaseFolderQuery +{ + /** + * + * count how many direct contents a folder has + * + * @param int $parent folder id + * @return int + */ + public static function countChild($parent) + { + return self::create()->filterByParent($parent)->count(); + } + /** + * find all contents for a given folder. + * + * @param $folderId the folder id or an array of id + * @param int $depth max depth you want to search + * @param int $currentPosition don't change this param, it is used for recursion + * @return \Thelia\Model\Folder[] + */ + public static function findAllChild($folderId, $depth = 0, $currentPosition = 0) + { + $result = array(); + + if(is_array($folderId)) { + foreach($folderId as $folderSingleId) { + $result = array_merge($result, (array) self::findAllChild($folderSingleId, $depth, $currentPosition)); + } + } else { + $currentPosition++; + + if($depth == $currentPosition && $depth != 0) return; + + $categories = self::create() + ->filterByParent($folderId) + ->find(); + + + foreach ($categories as $folder) { + array_push($result, $folder); + $result = array_merge($result, (array) self::findAllChild($folder->getId(), $depth, $currentPosition)); + } + } + + return $result; + } } // FolderQuery diff --git a/core/lib/Thelia/Model/Map/CurrencyTableMap.php b/core/lib/Thelia/Model/Map/CurrencyTableMap.php index c9a707d9a..b1251801a 100644 --- a/core/lib/Thelia/Model/Map/CurrencyTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyTableMap.php @@ -180,7 +180,7 @@ class CurrencyTableMap extends TableMap { $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', 'RESTRICT', 'Orders'); $this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), null, null, 'Carts'); - $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), null, null, 'ProductPrices'); + $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'CASCADE', null, 'ProductPrices'); $this->addRelation('CurrencyI18n', '\\Thelia\\Model\\CurrencyI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CurrencyI18ns'); } // buildRelations() @@ -205,6 +205,7 @@ class CurrencyTableMap extends TableMap // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. OrderTableMap::clearInstancePool(); + ProductPriceTableMap::clearInstancePool(); CurrencyI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/ProductPriceTableMap.php b/core/lib/Thelia/Model/Map/ProductPriceTableMap.php index 2b231321b..1a6274e2d 100644 --- a/core/lib/Thelia/Model/Map/ProductPriceTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductPriceTableMap.php @@ -169,8 +169,8 @@ class ProductPriceTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::MANY_TO_ONE, array('product_sale_elements_id' => 'id', ), null, null); - $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), null, null); + $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::MANY_TO_ONE, array('product_sale_elements_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'CASCADE', null); } // buildRelations() /** diff --git a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php index 2eb9a0b83..21c005f5c 100644 --- a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php @@ -178,7 +178,7 @@ class ProductSaleElementsTableMap extends TableMap $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'AttributeCombinations'); $this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'CartItems'); - $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'ProductPrices'); + $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), 'CASCADE', null, 'ProductPrices'); } // buildRelations() /** @@ -193,6 +193,15 @@ class ProductSaleElementsTableMap extends TableMap 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), ); } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to product_sale_elements * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ProductPriceTableMap::clearInstancePool(); + } /** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php new file mode 100755 index 000000000..71922dbab --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\Content; + +/** + * + * @author Etienne Roudeix + * + */ +class ContentTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\Content'; + } + + public function getTestedInstance() + { + return new Content($this->request, $this->dispatcher, $this->securityContext); + } + + public function getMandatoryArguments() + { + return array(); + } +} diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php new file mode 100755 index 000000000..2505c2fc2 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\Folder; + +/** + * + * @author Etienne Roudeix + * + */ +class FolderTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\Folder'; + } + + public function getTestedInstance() + { + return new Folder($this->request, $this->dispatcher, $this->securityContext); + } + + public function getMandatoryArguments() + { + return array(); + } +} diff --git a/install/faker.php b/install/faker.php index 85a338ebe..725bb26da 100755 --- a/install/faker.php +++ b/install/faker.php @@ -20,13 +20,21 @@ try { ->find(); $product->delete(); + $folder = Thelia\Model\FolderQuery::create() + ->find(); + $folder->delete(); + + $content = Thelia\Model\ContentQuery::create() + ->find(); + $content->delete(); + //first category $sweet = new Thelia\Model\Category(); $sweet->setParent(0); $sweet->setVisible(1); $sweet->setPosition(1); $sweet->setDescription($faker->text(255)); - $sweet->setTitle($faker->bs); + $sweet->setTitle($faker->text(20)); $sweet->save(); @@ -36,7 +44,7 @@ try { $jeans->setVisible(1); $jeans->setPosition(2); $jeans->setDescription($faker->text(255)); - $jeans->setTitle($faker->bs); + $jeans->setTitle($faker->text(20)); $jeans->save(); @@ -46,14 +54,14 @@ try { $other->setVisible(1); $other->setPosition(3); $other->setDescription($faker->text(255)); - $other->setTitle($faker->bs); + $other->setTitle($faker->text(20)); $other->save(); for ($i=1; $i <= 5; $i++) { $product = new \Thelia\Model\Product(); $product->addCategory($sweet); - $product->setTitle($faker->bs); + $product->setTitle($faker->text(20)); $product->setDescription($faker->text(250)); /* $product->setQuantity($faker->randomNumber(1,50)); $product->setPrice($faker->randomFloat(2, 20, 2500));*/ @@ -79,7 +87,7 @@ try { for ($i=1; $i <= 5; $i++) { $product = new \Thelia\Model\Product(); $product->addCategory($jeans); - $product->setTitle($faker->bs); + $product->setTitle($faker->text(20)); $product->setDescription($faker->text(250)); /* $product->setQuantity($faker->randomNumber(1,50)); $product->setPrice($faker->randomFloat(2, 20, 2500));*/ @@ -102,6 +110,60 @@ try { } + //folders and contents + for($i=0; $i<4; $i++) { + $folder = new Thelia\Model\Folder(); + $folder->setParent(0); + $folder->setVisible(rand(1, 10)>7 ? 0 : 1); + $folder->setPosition($i); + $folder->setTitle($faker->text(20)); + $folder->setDescription($faker->text(255)); + + $folder->save(); + + for($j=0; $jsetParent($folder->getId()); + $subfolder->setVisible(rand(1, 10)>7 ? 0 : 1); + $subfolder->setPosition($j); + $subfolder->setTitle($faker->text(20)); + $subfolder->setDescription($faker->text(255)); + + $subfolder->save(); + + for($k=0; $kaddFolder($subfolder); + $content->setVisible(rand(1, 10)>7 ? 0 : 1); + $content->setPosition($k); + $content->setTitle($faker->text(20)); + $content->setDescription($faker->text(255)); + + $content->save(); + } + } + } + + //features and features_av + for($i=0; $i<4; $i++) { + $feature = new Thelia\Model\Feature(); + $feature->setVisible(rand(1, 10)>7 ? 0 : 1); + $feature->setPosition($i); + $feature->setTitle($faker->text(20)); + $feature->setDescription($faker->text(50)); + + $feature->save(); + + for($j=0; $jsetFeature($feature); + $featureAv->setPosition($j); + $featureAv->setTitle($faker->text(20)); + $featureAv->setDescription($faker->text(255)); + + $featureAv->save(); + } + } $con->commit(); } catch (Exception $e) { diff --git a/install/thelia.sql b/install/thelia.sql index 3f587f40f..0cf0efe7f 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1349,10 +1349,12 @@ CREATE TABLE `product_price` INDEX `idx_product_price_currency_id` (`currency_id`), CONSTRAINT `fk_product_price_product_sale_elements_id` FOREIGN KEY (`product_sale_elements_id`) - REFERENCES `product_sale_elements` (`id`), + REFERENCES `product_sale_elements` (`id`) + ON DELETE CASCADE, CONSTRAINT `fk_product_price_currency_id` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`) + ON DELETE CASCADE ) ENGINE=InnoDB; -- --------------------------------------------------------------------- diff --git a/local/config/schema.xml b/local/config/schema.xml index cea0b7763..46850f8b2 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,4 +1,4 @@ - + @@ -990,10 +990,10 @@ - + - + diff --git a/templates/default/bug.html b/templates/default/bug.html index a1bc296ac..e69de29bb 100644 --- a/templates/default/bug.html +++ b/templates/default/bug.html @@ -1,4 +0,0 @@ -{loop name="cat" type="category" id="99999"} - {loop name="prod" type="product" category="#ID"} - {/loop} -{/loop} \ No newline at end of file diff --git a/templates/default/folder.html b/templates/default/folder.html new file mode 100755 index 000000000..7d12036f9 --- /dev/null +++ b/templates/default/folder.html @@ -0,0 +1,16 @@ +{loop name="folder0" type="folder" parent="0" order="alpha_reverse"} +
+

FOLDER : #TITLE

+ {loop name="folder1" type="folder" parent="#ID"} +
+

SUBFOLDER : #TITLE (#LOOP_COUNT / #LOOP_TOTAL)

+ {loop name="content" type="content" folder="#ID"} +
+

CONTENT : #TITLE

+

#DESCRIPTION

+
+ {/loop} +
+ {/loop} +
+{/loop} \ No newline at end of file