rename /install dir

This commit is contained in:
Manuel Raynaud
2014-04-17 17:49:15 +02:00
parent 50ac1a0318
commit 96a3742945
126 changed files with 18 additions and 18 deletions

0
setup/.gitkeep Executable file
View File

2
setup/.htaccess Normal file
View File

@@ -0,0 +1,2 @@
order deny,allow
deny from all

26
setup/INSTALL-TODO.txt Normal file
View File

@@ -0,0 +1,26 @@
A faire dans la procédure d'install
-----------------------------------
Variables Config à initialiser:
- base_admin_template : chemin du template admin relatif au repertoire template (ex. admin/default)
- default_locale : la locale par défaut (ex. en_US), à utiliser pour les fichiers de traduction
- asset_dir_from_web_root : le chemin relatif à /web du repertoires des assets (ex. assets)
- active_template: chemin du template front relatif au repertoire template (ex. default)
- thelia_version: la version de Thelia (ex. 2.0.0 alpha)
- cart.priceEOF : durée de vie d'un prix dans le panier (par défaut 1 mois 60*60*24*30)
- cart.session_only : pour rattacher le panier uniquement à la session (défaut 0 donc cookie crée)
- cart.cookie_lifetime : durée de vie du cookie du panier (défaut 1 an 60*60*24*365)
- one_domain_foreach_lang : un domaine par langue, défaut 0
- session_config.default : laisser la configuration par défaut de la session
- session_config.save_path : dossier en absolu dans lequel les sessions sont enregistrés
- default_lang_without_translation : si pas de traduction, prendre la traduction par défaut
- password.length : longueur du mot de passe, défaut 4
- form.secret : token csrf
- verifyStock : vérification du stock lors du paiement/ajout au panier. Defaut 1
- default_images_quality_percent : qualité par défaut des images générées (0 à 100, défaut: 75).
- original_image_delivery_mode : mode de mise à disposition des images originales (full resolution) dans le cache. 'symlink' pour un lien symbolique, 'copy' pour une copie
- images_library_path : chemin vers le répertoire où sont stockés les images source (defaut: local/media/images)
- image_cache_dir_from_web_root : le repértoire de base où sont cachées les images, relatif à /web (cache/images)
- imagine_graphic_driver : le drivers utilisé par Imagine (gd, imagik, gmagick), defaut: 'gd'
- process_assets : ne pas processer les assets pour de meilleurs perfs (attention, les modifs sur les fichiers ne seront plus reportées !)

Binary file not shown.

817
setup/faker.php Normal file
View File

@@ -0,0 +1,817 @@
<?php
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Condition\ConditionFactory;
use Thelia\Condition\Implementation\MatchForEveryone;
use Thelia\Condition\Implementation\MatchForTotalAmount;
use Thelia\Condition\Implementation\MatchForXArticles;
use Thelia\Condition\Operators;
use Thelia\Coupon\FacadeInterface;
use Thelia\Condition\ConditionCollection;
use Thelia\Coupon\Type\RemoveXAmount;
use Thelia\Coupon\Type\RemoveXPercent;
if (php_sapi_name() != 'cli') {
throw new \Exception('this script can only be launched with cli sapi');
}
require __DIR__ . '/../core/bootstrap.php';
$thelia = new Thelia\Core\Thelia("dev", true);
$thelia->boot();
$faker = Faker\Factory::create();
$con = \Propel\Runtime\Propel::getConnection(
Thelia\Model\Map\ProductTableMap::DATABASE_NAME
);
$con->beginTransaction();
// Intialize URL management
$url = new Thelia\Tools\URL();
$currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne();
try {
$stmt = $con->prepare("SET foreign_key_checks = 0");
$stmt->execute();
echo "Clearing tables\n";
$productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create()
->find();
$productAssociatedContent->delete();
$categoryAssociatedContent = Thelia\Model\CategoryAssociatedContentQuery::create()
->find();
$categoryAssociatedContent->delete();
$featureProduct = Thelia\Model\FeatureProductQuery::create()
->find();
$featureProduct->delete();
$attributeCombination = Thelia\Model\AttributeCombinationQuery::create()
->find();
$attributeCombination->delete();
$feature = Thelia\Model\FeatureQuery::create()
->find();
$feature->delete();
$feature = Thelia\Model\FeatureI18nQuery::create()
->find();
$feature->delete();
$featureAv = Thelia\Model\FeatureAvQuery::create()
->find();
$featureAv->delete();
$featureAv = Thelia\Model\FeatureAvI18nQuery::create()
->find();
$featureAv->delete();
$attribute = Thelia\Model\AttributeQuery::create()
->find();
$attribute->delete();
$attribute = Thelia\Model\AttributeI18nQuery::create()
->find();
$attribute->delete();
$attributeAv = Thelia\Model\AttributeAvQuery::create()
->find();
$attributeAv->delete();
$attributeAv = Thelia\Model\AttributeAvI18nQuery::create()
->find();
$attributeAv->delete();
$category = Thelia\Model\CategoryQuery::create()
->find();
$category->delete();
$category = Thelia\Model\CategoryI18nQuery::create()
->find();
$category->delete();
$product = Thelia\Model\ProductQuery::create()
->find();
$product->delete();
$product = Thelia\Model\ProductI18nQuery::create()
->find();
$product->delete();
$customer = Thelia\Model\CustomerQuery::create()
->find();
$customer->delete();
$admin = Thelia\Model\AdminQuery::create()
->find();
$admin->delete();
$folder = Thelia\Model\FolderQuery::create()
->find();
$folder->delete();
$folder = Thelia\Model\FolderI18nQuery::create()
->find();
$folder->delete();
$content = Thelia\Model\ContentQuery::create()
->find();
$content->delete();
$content = Thelia\Model\ContentI18nQuery::create()
->find();
$content->delete();
$accessory = Thelia\Model\AccessoryQuery::create()
->find();
$accessory->delete();
$stock = \Thelia\Model\ProductSaleElementsQuery::create()
->find();
$stock->delete();
$productPrice = \Thelia\Model\ProductPriceQuery::create()
->find();
$productPrice->delete();
\Thelia\Model\ProductImageQuery::create()->find()->delete();
\Thelia\Model\CategoryImageQuery::create()->find()->delete();
\Thelia\Model\FolderImageQuery::create()->find()->delete();
\Thelia\Model\ContentImageQuery::create()->find()->delete();
\Thelia\Model\ProductDocumentQuery::create()->find()->delete();
\Thelia\Model\CategoryDocumentQuery::create()->find()->delete();
\Thelia\Model\FolderDocumentQuery::create()->find()->delete();
\Thelia\Model\ContentDocumentQuery::create()->find()->delete();
\Thelia\Model\CouponQuery::create()->find()->delete();
$stmt = $con->prepare("SET foreign_key_checks = 1");
$stmt->execute();
echo "Creating customers\n";
//customer
$customer = new Thelia\Model\Customer();
$customer->createOrUpdate(
1,
"thelia",
"thelia",
"5 rue rochon",
"",
"",
"0102030405",
"0601020304",
"63000",
"clermont-ferrand",
64,
"test@thelia.net",
"azerty"
);
for ($j = 0; $j <= 3; $j++) {
$address = new Thelia\Model\Address();
$address->setLabel($faker->text(20))
->setTitleId(rand(1,3))
->setFirstname($faker->firstname)
->setLastname($faker->lastname)
->setAddress1($faker->streetAddress)
->setAddress2($faker->streetAddress)
->setAddress3($faker->streetAddress)
->setCellphone($faker->phoneNumber)
->setPhone($faker->phoneNumber)
->setZipcode($faker->postcode)
->setCity($faker->city)
->setCountryId(64)
->setCustomer($customer)
->save()
;
}
for ($i=0; $i<3; $i++) {
$admin = new Thelia\Model\Admin();
$admin
->setFirstname($faker->firstname)
->setLastname($faker->lastname)
->setLogin($faker->firstname)
->setPassword('azerty')
->setLocale('en_US')
->save();
}
for ($i = 0; $i < 50; $i++) {
$customer = new Thelia\Model\Customer();
$customer->createOrUpdate(
rand(1,3),
$faker->firstname,
$faker->lastname,
$faker->streetAddress,
$faker->streetAddress,
$faker->streetAddress,
$faker->phoneNumber,
$faker->phoneNumber,
$faker->postcode,
$faker->city,
64,
$faker->email,
"azerty".$i
);
for ($j = 0; $j <= 3; $j++) {
$address = new Thelia\Model\Address();
$address->setLabel($faker->text(20))
->setTitleId(rand(1,3))
->setFirstname($faker->firstname)
->setLastname($faker->lastname)
->setAddress1($faker->streetAddress)
->setAddress2($faker->streetAddress)
->setAddress3($faker->streetAddress)
->setCellphone($faker->phoneNumber)
->setPhone($faker->phoneNumber)
->setZipcode($faker->postcode)
->setCity($faker->city)
->setCountryId(64)
->setCustomer($customer)
->save()
;
}
}
echo "Creating features\n";
//features and features_av
$featureList = array();
for ($i=0; $i<4; $i++) {
$feature = new Thelia\Model\Feature();
$feature->setVisible(1);
$feature->setPosition($i);
setI18n($faker, $feature);
$feature->save();
$featureId = $feature->getId();
$featureList[$featureId] = array();
for ($j=0; $j<rand(-2, 5); $j++) { //let a chance for no av
$featureAv = new Thelia\Model\FeatureAv();
$featureAv->setFeature($feature);
$featureAv->setPosition($j);
setI18n($faker, $featureAv);
$featureAv->save();
$featureList[$featureId][] = $featureAv->getId();
}
}
echo "Creating attributes\n";
//attributes and attributes_av
$attributeList = array();
for ($i=0; $i<4; $i++) {
$attribute = new Thelia\Model\Attribute();
$attribute->setPosition($i);
setI18n($faker, $attribute);
$attribute->save();
$attributeId = $attribute->getId();
$attributeList[$attributeId] = array();
for ($j=0; $j<rand(1, 5); $j++) {
$attributeAv = new Thelia\Model\AttributeAv();
$attributeAv->setAttribute($attribute);
$attributeAv->setPosition($j);
setI18n($faker, $attributeAv);
$attributeAv->save();
$attributeList[$attributeId][] = $attributeAv->getId();
}
}
echo "Creating templates\n";
$template = new Thelia\Model\Template();
setI18n($faker, $template, array("Name" => 20));
$template->save();
foreach ($attributeList as $attributeId => $attributeAvId) {
$at = new Thelia\Model\AttributeTemplate();
$at
->setTemplate($template)
->setAttributeId($attributeId)
->save();
}
foreach ($featureList as $featureId => $featureAvId) {
$ft = new Thelia\Model\FeatureTemplate();
$ft
->setTemplate($template)
->setFeatureId($featureId)
->save();
}
echo "Creating folders and contents\n";
//folders and contents
$contentIdList = array();
for ($i=0; $i<4; $i++) {
$folder = new Thelia\Model\Folder();
$folder->setParent(0);
$folder->setVisible(1);
$folder->setPosition($i+1);
setI18n($faker, $folder);
$folder->save();
$image = new \Thelia\Model\FolderImage();
$image->setFolderId($folder->getId());
generate_image($image, 'folder', $folder->getId());
$document = new \Thelia\Model\FolderDocument();
$document->setFolderId($folder->getId());
generate_document($document, 'folder', $folder->getId());
for ($j=0; $j<3; $j++) {
$subfolder = new Thelia\Model\Folder();
$subfolder->setParent($folder->getId());
$subfolder->setVisible(1);
$subfolder->setPosition($j+1);
setI18n($faker, $subfolder);
$subfolder->save();
$image = new \Thelia\Model\FolderImage();
$image->setFolderId($subfolder->getId());
generate_image($image, 'folder', $subfolder->getId());
$document = new \Thelia\Model\FolderDocument();
$document->setFolderId($folder->getId());
generate_document($document, 'folder', $subfolder->getId());
for ($k=0; $k<4; $k++) {
$content = new Thelia\Model\Content();
$content->addFolder($subfolder);
$contentFolders = $content->getContentFolders();
$collection = new \Propel\Runtime\Collection\Collection();
$collection->prepend($contentFolders[0]->setDefaultFolder(1));
$content->setContentFolders($collection);
$content->setVisible(1);
$content->setPosition($k+1);
setI18n($faker, $content);
$content->save();
$contentId = $content->getId();
$contentIdList[] = $contentId;
$image = new \Thelia\Model\ContentImage();
$image->setContentId($contentId);
generate_image($image, 'content', $contentId);
$document = new \Thelia\Model\ContentDocument();
$document->setContentId($contentId);
generate_document($document, 'content', $contentId);
}
}
}
echo "Creating categories and products\n";
//categories and products
$productIdList = array();
$categoryIdList = array();
for ($i=1; $i<20; $i++) {
$category = createCategory($faker, 0, $i, $categoryIdList, $contentIdList);
for ($j=1; $j<rand(0, 20); $j++) {
$subcategory = createCategory($faker, $category->getId(), $j, $categoryIdList, $contentIdList);
for ($k=0; $k<rand(0, 20); $k++) {
createProduct($faker, $subcategory, $k, $template, $productIdList);
}
}
for ($k=1; $k<rand(1, 50); $k++) {
createProduct($faker, $category, $k, $template, $productIdList);
}
}
foreach ($productIdList as $productId) {
//add random accessories - or not
$alreadyPicked = array();
for ($i=1; $i<rand(0, 4); $i++) {
$accessory = new Thelia\Model\Accessory();
do {
$pick = array_rand($productIdList, 1);
} while (in_array($pick, $alreadyPicked));
$alreadyPicked[] = $pick;
$accessory->setAccessory($productIdList[$pick])
->setProductId($productId)
->setPosition($i)
->save();
}
//add random associated content
$alreadyPicked = array();
for ($i=1; $i<rand(0, 3); $i++) {
$productAssociatedContent = new Thelia\Model\ProductAssociatedContent();
do {
$pick = array_rand($contentIdList, 1);
\Thelia\Log\Tlog::getInstance()->debug("pick : $pick");
} while (in_array($pick, $alreadyPicked));
$alreadyPicked[] = $pick;
$productAssociatedContent->setContentId($contentIdList[$pick])
->setProductId($productId)
->setPosition($i)
->save();
}
//associate PSE and stocks to products
for ($i=0; $i<rand(1,7); $i++) {
$stock = new \Thelia\Model\ProductSaleElements();
$stock->setProductId($productId);
$stock->setRef($productId . '_' . $i . '_' . $faker->randomNumber(8));
$stock->setQuantity($faker->randomNumber(1,50));
$stock->setPromo($faker->randomNumber(0,1));
$stock->setNewness($faker->randomNumber(0,1));
$stock->setWeight($faker->randomFloat(2, 1, 5));
$stock->setIsDefault($i == 0);
$stock->setEanCode(substr(str_shuffle("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 13));
$stock->save();
$productPrice = new \Thelia\Model\ProductPrice();
$productPrice->setProductSaleElements($stock);
$productPrice->setCurrency($currency);
$productPrice->setPrice($faker->randomFloat(2, 20, 250));
$productPrice->setPromoPrice($faker->randomFloat(2, 20, 250));
$productPrice->save();
//associate attributes - or not - to PSE
$alreadyPicked = array();
for ($i=0; $i<rand(-2,count($attributeList)); $i++) {
$featureProduct = new Thelia\Model\AttributeCombination();
do {
$pick = array_rand($attributeList, 1);
} while (in_array($pick, $alreadyPicked));
$alreadyPicked[] = $pick;
$featureProduct->setAttributeId($pick)
->setAttributeAvId($attributeList[$pick][array_rand($attributeList[$pick], 1)])
->setProductSaleElements($stock)
->save();
}
}
//associate features to products
foreach ($featureList as $featureId => $featureAvId) {
$featureProduct = new Thelia\Model\FeatureProduct();
$featureProduct->setProductId($productId)
->setFeatureId($featureId);
if (count($featureAvId) > 0) { //got some av
$featureProduct->setFeatureAvId(
$featureAvId[array_rand($featureAvId, 1)]
);
} else { //no av
$featureProduct->setFreeTextValue($faker->text(10));
}
$featureProduct->save();
}
}
echo "Generating coupons fixtures\n";
generateCouponFixtures($thelia);
$con->commit();
echo "Successfully terminated.\n";
} catch (Exception $e) {
echo "error : ".$e->getMessage()."\n";
$con->rollBack();
}
function createProduct($faker, Thelia\Model\Category $category, $position, $template, &$productIdList)
{
$product = new Thelia\Model\Product();
$product->setRef($category->getId() . '_' . $position . '_' . $faker->randomNumber(8));
$product->addCategory($category);
$product->setVisible(1);
$productCategories = $product->getProductCategories();
$collection = new \Propel\Runtime\Collection\Collection();
$collection->prepend($productCategories[0]->setDefaultCategory(1));
$product->setProductCategories($collection);
$product->setVisible(1);
$product->setPosition($position);
$product->setTaxRuleId(1);
$product->setTemplate($template);
setI18n($faker, $product);
$product->save();
$productId = $product->getId();
$productIdList[] = $productId;
$image = new \Thelia\Model\ProductImage();
$image->setProductId($productId);
generate_image($image, 'product', $productId);
$document = new \Thelia\Model\ProductDocument();
$document->setProductId($productId);
generate_document($document, 'product', $productId);
return $product;
}
function createCategory($faker, $parent, $position, &$categoryIdList, $contentIdList)
{
$category = new Thelia\Model\Category();
$category->setParent($parent);
$category->setVisible(1);
$category->setPosition($position);
setI18n($faker, $category);
$category->save();
$categoryId = $category->getId();
$categoryIdList[] = $categoryId;
//add random associated content
$alreadyPicked = array();
for ($i=1; $i<rand(0, 3); $i++) {
$categoryAssociatedContent = new Thelia\Model\CategoryAssociatedContent();
do {
$pick = array_rand($contentIdList, 1);
} while (in_array($pick, $alreadyPicked));
$alreadyPicked[] = $pick;
$categoryAssociatedContent->setContentId($contentIdList[$pick])
->setCategoryId($categoryId)
->setPosition($i)
->save();
}
$image = new \Thelia\Model\CategoryImage();
$image->setCategoryId($categoryId);
generate_image($image, 'category', $categoryId);
$document = new \Thelia\Model\CategoryDocument();
$document->setCategoryId($categoryId);
generate_document($document, 'category', $categoryId);
return $category;
}
function generate_image($image, $typeobj, $id)
{
global $faker;
$image
->setTitle($faker->text(20))
->setDescription($faker->text(250))
->setChapo($faker->text(40))
->setPostscriptum($faker->text(40))
->setFile(sprintf("sample-image-%s.png", $id))
->save()
;
// Generate images
$imagine = new Imagine\Gd\Imagine();
$image = $imagine->create(new Imagine\Image\Box(320,240), new Imagine\Image\Color('#E9730F'));
$white = new Imagine\Image\Color('#FFF');
$font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 14, $white);
$tbox = $font->box("THELIA");
$image->draw()->text("THELIA", $font, new Imagine\Image\Point((320 - $tbox->getWidth()) / 2, 30));
$str = sprintf("%s sample image", ucfirst($typeobj));
$tbox = $font->box($str);
$image->draw()->text($str, $font, new Imagine\Image\Point((320 - $tbox->getWidth()) / 2, 80));
$font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 18, $white);
$str = sprintf("%s ID %d", strtoupper($typeobj), $id);
$tbox = $font->box($str);
$image->draw()->text($str, $font, new Imagine\Image\Point((320 - $tbox->getWidth()) / 2, 180));
$image->draw()
->line(new Imagine\Image\Point(0, 0), new Imagine\Image\Point(319, 0), $white)
->line(new Imagine\Image\Point(319, 0), new Imagine\Image\Point(319, 239), $white)
->line(new Imagine\Image\Point(319, 239), new Imagine\Image\Point(0,239), $white)
->line(new Imagine\Image\Point(0, 239), new Imagine\Image\Point(0, 0), $white)
;
$image_file = sprintf("%s/../local/media/images/%s/sample-image-%s.png", __DIR__, $typeobj, $id);
if (! is_dir(dirname($image_file))) mkdir(dirname($image_file), 0777, true);
$image->save($image_file);
}
function generate_document($document, $typeobj, $id)
{
global $faker;
$document
->setTitle($faker->text(20))
->setDescription($faker->text(250))
->setChapo($faker->text(40))
->setPostscriptum($faker->text(40))
->setFile(sprintf("sample-document-%s.txt", $id))
->save()
;
$document_file = sprintf("%s/../local/media/documents/%s/sample-document-%s.txt", __DIR__, $typeobj, $id);
if (! is_dir(dirname($document_file))) mkdir(dirname($document_file), 0777, true);
file_put_contents($document_file, $faker->text(256));
}
function setI18n($faker, &$object, $fields = array('Title' => 20, 'Description' => 50) )
{
$localeList = $localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT');
foreach ($localeList as $locale) {
$object->setLocale($locale);
foreach ($fields as $name => $length) {
$func = "set".ucfirst(strtolower($name));
$object->$func($locale . ' : ' . $faker->text($length));
}
}
}
/**
* Generate Coupon fixtures
*/
function generateCouponFixtures(\Thelia\Core\Thelia $thelia)
{
/** @var $container ContainerInterface Service Container */
$container = $thelia->getContainer();
/** @var FacadeInterface $adapter */
$adapter = $container->get('thelia.facade');
// Coupons
$coupon1 = new Thelia\Model\Coupon();
$coupon1->setCode('XMAS');
$coupon1->setType('thelia.coupon.type.remove_x_amount');
$coupon1->setTitle('Christmas coupon');
$coupon1->setShortDescription('Coupon for Christmas removing 10€ if your total checkout is more than 40€');
$coupon1->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla.
Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla.
Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros.
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.');
$coupon1->setEffects(array(
RemoveXAmount::INPUT_AMOUNT_NAME => 10.00,
));
$coupon1->setIsUsed(true);
$coupon1->setIsEnabled(true);
$date = new \DateTime();
$coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months")));
$condition1 = new MatchForTotalAmount($adapter);
$operators = array(
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmount::INPUT2 => Operators::EQUAL
);
$values = array(
MatchForTotalAmount::INPUT1 => 40.00,
MatchForTotalAmount::INPUT2 => 'EUR'
);
$condition1->setValidatorsFromForm($operators, $values);
$condition2 = new MatchForTotalAmount($adapter);
$operators = array(
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
MatchForTotalAmount::INPUT2 => Operators::EQUAL
);
$values = array(
MatchForTotalAmount::INPUT1 => 400.00,
MatchForTotalAmount::INPUT2 => 'EUR'
);
$condition2->setValidatorsFromForm($operators, $values);
$conditions = new ConditionCollection();
$conditions[] = $condition1;
$conditions[] = $condition2;
/** @var ConditionFactory $conditionFactory */
$conditionFactory = $container->get('thelia.condition.factory');
$serializedConditions = $conditionFactory->serializeConditionCollection($conditions);
$coupon1->setSerializedConditions($serializedConditions);
$coupon1->setMaxUsage(40);
$coupon1->setIsCumulative(true);
$coupon1->setIsRemovingPostage(false);
$coupon1->setIsAvailableOnSpecialOffers(true);
$coupon1->save();
// Coupons
$coupon2 = new Thelia\Model\Coupon();
$coupon2->setCode('SPRINGBREAK');
$coupon2->setType('thelia.coupon.type.remove_x_percent');
$coupon2->setTitle('Springbreak coupon');
$coupon2->setShortDescription('Coupon for Springbreak removing 10% if you have more than 4 articles in your cart');
$coupon2->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla.
Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla.
Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros.
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.');
$coupon2->setEffects(array(
RemoveXPercent::INPUT_AMOUNT_NAME => 0.00,
RemoveXPercent::INPUT_PERCENTAGE_NAME => 10.00,
));
$coupon2->setIsUsed(true);
$coupon2->setIsEnabled(true);
$date = new \DateTime();
$coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 1 months")));
$condition1 = new MatchForXArticles($adapter);
$operators = array(
MatchForXArticles::INPUT1 => Operators::SUPERIOR,
);
$values = array(
MatchForXArticles::INPUT1 => 4,
);
$condition1->setValidatorsFromForm($operators, $values);
$conditions = new ConditionCollection();
$conditions[] = $condition1;
/** @var ConditionFactory $conditionFactory */
$conditionFactory = $container->get('thelia.condition.factory');
$serializedConditions = $conditionFactory->serializeConditionCollection($conditions);
$coupon2->setSerializedConditions($serializedConditions);
$coupon2->setMaxUsage(-1);
$coupon2->setIsCumulative(false);
$coupon2->setIsRemovingPostage(true);
$coupon2->setIsAvailableOnSpecialOffers(true);
$coupon2->save();
// Coupons
$coupon3 = new Thelia\Model\Coupon();
$coupon3->setCode('OLD');
$coupon3->setType('thelia.coupon.type.remove_x_percent');
$coupon3->setTitle('Old coupon');
$coupon3->setShortDescription('Coupon for Springbreak removing 10% if you have more than 4 articles in your cart');
$coupon3->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla.
Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla.
Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros.
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.');
$coupon3->setEffects(array(
RemoveXPercent::INPUT_AMOUNT_NAME => 0.00,
RemoveXPercent::INPUT_PERCENTAGE_NAME => 10.00,
));
$coupon3->setIsUsed(false);
$coupon3->setIsEnabled(false);
$date = new \DateTime();
$coupon3->setExpirationDate($date->setTimestamp(strtotime("today + 2 months")));
$condition1 = new MatchForEveryone($adapter);
$operators = array();
$values = array();
$condition1->setValidatorsFromForm($operators, $values);
$conditions = new ConditionCollection();
$conditions[] = $condition1;
/** @var ConditionFactory $constraintCondition */
$constraintCondition = $container->get('thelia.condition.factory');
$serializedConditions = $constraintCondition->serializeConditionCollection($conditions);
$coupon3->setSerializedConditions($serializedConditions);
$coupon3->setMaxUsage(-1);
$coupon3->setIsCumulative(true);
$coupon3->setIsRemovingPostage(false);
$coupon3->setIsAvailableOnSpecialOffers(false);
$coupon3->save();
}

View File

@@ -0,0 +1,168 @@
<?php
if (php_sapi_name() != 'cli') {
throw new \Exception('this script can only be launched with cli sapi');
}
require __DIR__ . '/../core/bootstrap.php';
$thelia = new Thelia\Core\Thelia("dev", true);
$faker = Faker\Factory::create();
$con = \Propel\Runtime\Propel::getConnection(Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
$currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne();
try {
$stmt = $con->prepare("SET foreign_key_checks = 0");
$stmt->execute();
$productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create()
->find();
$productAssociatedContent->delete();
$categoryAssociatedContent = Thelia\Model\CategoryAssociatedContentQuery::create()
->find();
$categoryAssociatedContent->delete();
$attributeCategory = Thelia\Model\AttributeCategoryQuery::create()
->find();
$attributeCategory->delete();
$featureCategory = Thelia\Model\FeatureCategoryQuery::create()
->find();
$featureCategory->delete();
$featureProduct = Thelia\Model\FeatureProductQuery::create()
->find();
$featureProduct->delete();
$attributeCombination = Thelia\Model\AttributeCombinationQuery::create()
->find();
$attributeCombination->delete();
$feature = Thelia\Model\FeatureQuery::create()
->find();
$feature->delete();
$feature = Thelia\Model\FeatureI18nQuery::create()
->find();
$feature->delete();
$featureAv = Thelia\Model\FeatureAvQuery::create()
->find();
$featureAv->delete();
$featureAv = Thelia\Model\FeatureAvI18nQuery::create()
->find();
$featureAv->delete();
$attribute = Thelia\Model\AttributeQuery::create()
->find();
$attribute->delete();
$attribute = Thelia\Model\AttributeI18nQuery::create()
->find();
$attribute->delete();
$attributeAv = Thelia\Model\AttributeAvQuery::create()
->find();
$attributeAv->delete();
$attributeAv = Thelia\Model\AttributeAvI18nQuery::create()
->find();
$attributeAv->delete();
$category = Thelia\Model\CategoryQuery::create()
->find();
$category->delete();
$category = Thelia\Model\CategoryI18nQuery::create()
->find();
$category->delete();
$product = Thelia\Model\ProductQuery::create()
->find();
$product->delete();
$product = Thelia\Model\ProductI18nQuery::create()
->find();
$product->delete();
$customer = Thelia\Model\CustomerQuery::create()
->find();
$customer->delete();
$folder = Thelia\Model\FolderQuery::create()
->find();
$folder->delete();
$folder = Thelia\Model\FolderI18nQuery::create()
->find();
$folder->delete();
$content = Thelia\Model\ContentQuery::create()
->find();
$content->delete();
$content = Thelia\Model\ContentI18nQuery::create()
->find();
$content->delete();
$accessory = Thelia\Model\AccessoryQuery::create()
->find();
$accessory->delete();
$stock = \Thelia\Model\ProductSaleElementsQuery::create()
->find();
$stock->delete();
$productPrice = \Thelia\Model\ProductPriceQuery::create()
->find();
$productPrice->delete();
$stmt = $con->prepare("SET foreign_key_checks = 1");
$stmt->execute();
//categories and products
for ($i=0; $i<100; $i++) {
$category = new Thelia\Model\Category();
$category->setParent(0);
$category->setVisible(1);
$category->setPosition($i);
setI18n($faker, $category);
$category->save();
for ($j=0; $j<10; $j++) {
$product = new Thelia\Model\Product();
$product->setRef($category->getId() . '_' . $j . '_' . $faker->randomNumber(8));
$product->addCategory($category);
$product->setVisible(1);
$product->setPosition($j);
setI18n($faker, $product);
$product->save();
}
}
$con->commit();
} catch (Exception $e) {
echo "error : ".$e->getMessage()."\n";
$con->rollBack();
}
function setI18n($faker, &$object, $fields = array('Title' => 20, 'Description' => 50) )
{
$localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT');
foreach ($localeList as $locale) {
$object->setLocale($locale);
foreach ($fields as $name => $length) {
$func = "set$name";
$object->$func($locale . ' : ' . $faker->text($length));
}
}
}

121
setup/faker_add_ecotax.php Normal file
View File

@@ -0,0 +1,121 @@
<?php
if (php_sapi_name() != 'cli') {
throw new \Exception('this script can only be launched with cli sapi');
}
require __DIR__ . '/../core/bootstrap.php';
$thelia = new Thelia\Core\Thelia("dev", true);
$thelia->boot();
$faker = Faker\Factory::create();
$con = \Propel\Runtime\Propel::getConnection(
Thelia\Model\Map\ProductTableMap::DATABASE_NAME
);
$con->beginTransaction();
// Intialize URL management
try {
$options = getopt('f::e::');
$forceEcotaxFeatureId = $options['f'];
if (null !== $forceEcotaxFeatureId && !filter_var($forceEcotaxFeatureId, FILTER_VALIDATE_INT)) {
exit('[ERROR] bad value for f option\n');
}
$forceEcotaxId = $options['e'];
if (null !== $forceEcotaxId && !filter_var($forceEcotaxId, FILTER_VALIDATE_INT)) {
exit('[ERROR] bad value for e option\n');
}
echo "Adding Ecotax feature\n";
$feature = null;
if (null !== $forceEcotaxFeatureId) {
$feature = \Thelia\Model\FeatureQuery::create()->findPk($forceEcotaxFeatureId);
if (null === $feature) {
echo "Feature `$forceEcotaxFeatureId` not found\n";
}
}
if (null === $feature) {
$feature = new \Thelia\Model\Feature();
$feature->setVisible(1);
$feature->save();
echo sprintf("Ecotax feature added with ID \n", $feature->getId());
}
$fr = \Thelia\Model\Base\FeatureI18nQuery::create()
->filterByLocale('fr_FR')
->filterByFeature($feature)
->findOne();
if (null === $fr) {
$fr = new \Thelia\Model\FeatureI18n();
$fr->setLocale('fr_FR')
->setFeature($feature);
}
$fr->setTitle('Ecotaxe');
$fr->save($con);
$us = \Thelia\Model\Base\FeatureI18nQuery::create()
->filterByLocale('en_US')
->filterByFeature($feature)
->findOne();
if (null === $us) {
$us = new \Thelia\Model\FeatureI18n();
$us->setLocale('en_US')
->setFeature($feature);
}
$us->setTitle('Ecotax');
$us->save($con);
echo "Adding ecotax\n";
$tax = null;
if (null !== $forceEcotaxId) {
$tax = \Thelia\Model\TaxQuery::create()->findPk($forceEcotaxId);
if (null === $tax) {
echo "Tax `$forceEcotaxId` not found\n";
}
}
if (null === $tax) {
$tax = new \Thelia\Model\Tax();
$tax->setType('FeatureFixAmountTaxType')
->setSerializedRequirements(
base64_encode(sprintf('{"feature":%s}', $feature->getId()))
);
$tax->save();
echo sprintf("Ecotax added with ID \n", $tax->getId());
}
$fr = \Thelia\Model\Base\TaxI18nQuery::create()
->filterByLocale('fr_FR')
->filterByTax($tax)
->findOne();
if (null === $fr) {
$fr = new \Thelia\Model\TaxI18n();
$fr->setLocale('fr_FR')
->setTax($tax);
}
$fr->setTitle('Ecotaxe');
$fr->save($con);
$us = \Thelia\Model\Base\TaxI18nQuery::create()
->filterByLocale('en_US')
->filterByTax($tax)
->findOne();
if (null === $us) {
$us = new \Thelia\Model\TaxI18n();
$us->setLocale('en_US')
->setTax($tax);
}
$us->setTitle('Ecotax');
$us->save($con);
$con->commit();
echo "Successfully terminated.\n";
} catch (Exception $e) {
echo "error : ".$e->getMessage()."\n";
$con->rollBack();
}

371
setup/import.php Normal file
View File

@@ -0,0 +1,371 @@
<?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/>. */
/* */
/*************************************************************************************/
if (php_sapi_name() != 'cli') {
throw new \Exception('this script can only be launched with cli sapi');
}
require __DIR__ . '/../core/bootstrap.php';
$thelia = new Thelia\Core\Thelia("dev", true);
$thelia->boot();
$faker = Faker\Factory::create();
// Intialize URL management
$url = new Thelia\Tools\URL();
$con = \Propel\Runtime\Propel::getConnection(
Thelia\Model\Map\ProductTableMap::DATABASE_NAME
);
$con->beginTransaction();
try {
$stmt = $con->prepare("SET foreign_key_checks = 0");
$stmt->execute();
clearTables($con);
$stmt = $con->prepare("SET foreign_key_checks = 1");
$stmt->execute();
$categories = createCategories($con);
$color = createColors($con);
$brand = createBrand($con);
echo "creating templates\n";
$template = new \Thelia\Model\Template();
$template
->setLocale('fr_FR')
->setName('template de démo')
->setLocale('en_US')
->setName('demo template')
->save($con);
$at = new Thelia\Model\AttributeTemplate();
$at
->setTemplate($template)
->setAttribute($color)
->save($con);
$ft = new Thelia\Model\FeatureTemplate();
$ft
->setTemplate($template)
->setFeature($brand)
->save($con);
echo "end creating templates\n";
createProduct($faker, $categories, $template, $color, $brand, $con);
$con->commit();
} catch (Exception $e) {
echo "error : ".$e->getMessage()."\n";
$con->rollBack();
}
function createProduct($faker, $categories, $template, $attribute, $feature, $con)
{
echo "start creating products\n";
$fileSystem = new \Symfony\Component\Filesystem\Filesystem();
if (($handle = fopen(THELIA_ROOT . '/setup/import/products.csv', "r")) !== FALSE) {
$row=0;
while (($data = fgetcsv($handle, 100000, ";")) !== FALSE) {
$row++;
if($row == 1) continue;
$product = new \Thelia\Model\Product();
$productCategories = explode(';', $data[13]);
$product
->setRef($data[0])
->setVisible(1)
->setTaxRuleId(1)
->setTemplate($template)
;
foreach ($productCategories as $productCategory) {
$productCategory = trim($productCategory);
if (array_key_exists($productCategory, $categories)) {
$product->addCategory($categories[$productCategory]);
}
}
$product
->setLocale('en_US')
->setTitle($data[1])
->setChapo($data[2])
->setDescription($data[4])
->setPostscriptum($data[6])
->setLocale('fr_Fr')
->setTitle($data[1])
->setChapo($data[3])
->setDescription($data[5])
->setPostscriptum($data[7])
->save($con);
$productCategories = $product->getProductCategories()->getFirst();
$productCategories->setDefaultCategory(true)
->save($con);
// Set the position
$product->setPosition($product->getNextPosition())->save();
$images = explode(';', $data[10]);
foreach ($images as $image) {
$image = trim($image);
if(empty($image)) continue;
$productImage = new \Thelia\Model\ProductImage();
$productImage
->setProduct($product)
->setFile($image)
->save($con);
$fileSystem->copy(THELIA_ROOT . 'setup/import/images/'.$image, THELIA_ROOT . 'local/media/images/product/'.$image, true);
}
$pses = explode(";", $data[12]);
foreach ($pses as $pse) {
if(empty($pse)) continue;
$stock = new \Thelia\Model\ProductSaleElements();
$stock->setProduct($product);
$stock->setRef($product->getId() . '_' . uniqid('', true));
$stock->setQuantity($faker->randomNumber(1,50));
if (!empty($data[9])) {
$stock->setPromo(1);
} else {
$stock->setPromo(0);
}
$stock->setNewness($faker->randomNumber(0,1));
$stock->setWeight($faker->randomFloat(2, 1,30));
$stock->save($con);
$productPrice = new \Thelia\Model\ProductPrice();
$productPrice->setProductSaleElements($stock);
$productPrice->setCurrencyId(1);
$productPrice->setPrice($data[8]);
$productPrice->setPromoPrice($data[9]);
$productPrice->save($con);
$attributeAv = \Thelia\Model\AttributeAvI18nQuery::create()
->filterByLocale('en_US')
->filterByTitle($pse)
->findOne($con);
$attributeCombination = new \Thelia\Model\AttributeCombination();
$attributeCombination
->setAttributeId($attribute->getId())
->setAttributeAvId($attributeAv->getId())
->setProductSaleElements($stock)
->save($con);
}
$productSaleElements = $product->getProductSaleElementss()->getFirst();
$productSaleElements->setIsDefault(1)->save($con);
$brand = $data[11];
$featurAv = \Thelia\Model\FeatureAvI18nQuery::create()
->filterByLocale('en_US')
->filterByTitle($brand)
->findOne($con);
$featureProduct = new Thelia\Model\FeatureProduct();
$featureProduct->setProduct($product)
->setFeatureId($feature->getId())
->setFeatureAvId($featurAv->getId())
->save($con)
;
}
}
echo "end creating products\n";
}
function createBrand($con)
{
echo "start creating brands feature\n";
if (($handle = fopen(THELIA_ROOT . '/setup/import/brand.csv', "r")) !== FALSE) {
$row=0;
$feature = new \Thelia\Model\Feature();
$feature
->setPosition(1)
->setLocale('fr_FR')
->setTitle('Marque')
->setLocale('en_US')
->setTitle('Brand');
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$row++;
$featureAv = new \Thelia\Model\FeatureAv();
$featureAv
->setPosition($row)
->setLocale('fr_FR')
->setTitle($data[0])
->setLocale('en_US')
->setTitle($data[0]);
$feature->addFeatureAv($featureAv);
}
$feature->save($con);
fclose($handle);
}
echo "brands feature created successfully\n";
return $feature;
}
function createCategories($con)
{
echo "start creating categories\n";
$categories = array();
if (($handle = fopen(THELIA_ROOT . '/setup/import/categories.csv', "r")) !== FALSE) {
$row=0;
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$row++;
if($row==1) continue;
$category = new \Thelia\Model\Category();
$category
->setVisible(1)
->setPosition($row-1)
->setParent(0)
->setLocale('fr_FR')
->setTitle(trim($data[0]))
->setLocale('en_US')
->setTitle(trim($data[1]))
->save($con);
$categories[trim($data[1])] = $category;
}
fclose($handle);
}
echo "categories created successfully\n";
return $categories;
}
function createColors($con)
{
echo "start creating colors attributes\n";
if (($handle = fopen(THELIA_ROOT . '/setup/import/colors.csv', "r")) !== FALSE) {
$row=0;
$attribute = new \Thelia\Model\Attribute();
$attribute
->setPosition(1)
->setLocale('fr_FR')
->setTitle('Couleur')
->setLocale('en_US')
->setTitle('Colors');
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$row++;
$attributeAv = new \Thelia\Model\AttributeAv();
$attributeAv
->setPosition($row)
->setLocale('fr_FR')
->setTitle($data[0])
->setLocale('en_US')
->setTitle($data[1]);
$attribute->addAttributeAv($attributeAv);
}
$attribute->save($con);
fclose($handle);
}
echo "colors attributes created with success\n";
return $attribute;
}
function clearTables($con)
{
$productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create()
->find($con);
$productAssociatedContent->delete($con);
$categoryAssociatedContent = Thelia\Model\CategoryAssociatedContentQuery::create()
->find($con);
$categoryAssociatedContent->delete($con);
$featureProduct = Thelia\Model\FeatureProductQuery::create()
->find($con);
$featureProduct->delete($con);
$attributeCombination = Thelia\Model\AttributeCombinationQuery::create()
->find($con);
$attributeCombination->delete($con);
$feature = Thelia\Model\FeatureQuery::create()
->find($con);
$feature->delete($con);
$feature = Thelia\Model\FeatureI18nQuery::create()
->find($con);
$feature->delete($con);
$featureAv = Thelia\Model\FeatureAvQuery::create()
->find($con);
$featureAv->delete($con);
$featureAv = Thelia\Model\FeatureAvI18nQuery::create()
->find($con);
$featureAv->delete($con);
$attribute = Thelia\Model\AttributeQuery::create()
->find($con);
$attribute->delete($con);
$attribute = Thelia\Model\AttributeI18nQuery::create()
->find($con);
$attribute->delete($con);
$attributeAv = Thelia\Model\AttributeAvQuery::create()
->find($con);
$attributeAv->delete($con);
$attributeAv = Thelia\Model\AttributeAvI18nQuery::create()
->find($con);
$attributeAv->delete($con);
$category = Thelia\Model\CategoryQuery::create()
->find($con);
$category->delete($con);
$category = Thelia\Model\CategoryI18nQuery::create()
->find($con);
$category->delete($con);
$product = Thelia\Model\ProductQuery::create()
->find($con);
$product->delete($con);
$product = Thelia\Model\ProductI18nQuery::create()
->find($con);
$product->delete($con);
$accessory = Thelia\Model\AccessoryQuery::create()
->find($con);
$accessory->delete($con);
$stock = \Thelia\Model\ProductSaleElementsQuery::create()
->find($con);
$stock->delete($con);
$productPrice = \Thelia\Model\ProductPriceQuery::create()
->find($con);
$productPrice->delete($con);
\Thelia\Model\ProductImageQuery::create()->find($con)->delete($con);
}

7
setup/import/brand.csv Normal file
View File

@@ -0,0 +1,7 @@
"MILAN"
"MAGIS"
"OXYO"
"OFFUS"
"PLINK"
"PARRY"
"TOKO"
1 MILAN
2 MAGIS
3 OXYO
4 OFFUS
5 PLINK
6 PARRY
7 TOKO

View File

@@ -0,0 +1,5 @@
"CATEGORIES FR";"CATEGORIES UK"
"Chaises";"Chairs"
"Tabourets";"Stools"
"Fauteuils";"Armchairs"
"Canapés";"Sofas"
1 CATEGORIES FR CATEGORIES UK
2 Chaises Chairs
3 Tabourets Stools
4 Fauteuils Armchairs
5 Canapés Sofas

13
setup/import/colors.csv Normal file
View File

@@ -0,0 +1,13 @@
"Bleu";"Blue"
"Jaune";"Yellow"
"Orange";"Orange"
"Rose";"Pink"
"Vert";"Green"
"Violet";"Purple"
"Rouge";"Red"
"Gris";"Gray"
"Noir";"Black"
"Beige";"Beige"
"Turquoise";"Turquoise"
"Marron";"Brown"
"Blanc";"White"
1 Bleu Blue
2 Jaune Yellow
3 Orange Orange
4 Rose Pink
5 Vert Green
6 Violet Purple
7 Rouge Red
8 Gris Gray
9 Noir Black
10 Beige Beige
11 Turquoise Turquoise
12 Marron Brown
13 Blanc White

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Some files were not shown because too many files have changed in this diff Show More