new faker entries

new category view
This commit is contained in:
Etienne Roudeix
2013-08-13 11:40:24 +02:00
parent b9bc56a748
commit c9485075d4
7 changed files with 256 additions and 199 deletions

View File

@@ -50,86 +50,108 @@ try {
->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->text(20));
$accessory = Thelia\Model\AccessoryQuery::create()
->find();
$accessory->delete();
$sweet->save();
//features and features_av
$featureList = array();
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));
//second category
$jeans = new Thelia\Model\Category();
$jeans->setParent(0);
$jeans->setVisible(1);
$jeans->setPosition(2);
$jeans->setDescription($faker->text(255));
$jeans->setTitle($faker->text(20));
$feature->save();
$featureId = $feature->getId();
$featureList[$featureId] = array();
$jeans->save();
//third category
$other = new Thelia\Model\Category();
$other->setParent($jeans->getId());
$other->setVisible(1);
$other->setPosition(3);
$other->setDescription($faker->text(255));
$other->setTitle($faker->text(20));
$other->save();
for ($i=1; $i <= 5; $i++) {
$product = new \Thelia\Model\Product();
$product->addCategory($sweet);
$product->setTitle($faker->text(20));
$product->setDescription($faker->text(250));
/* $product->setQuantity($faker->randomNumber(1,50));
$product->setPrice($faker->randomFloat(2, 20, 2500));*/
$product->setVisible(1);
$product->setPosition($i);
$product->setRef($faker->text(255));
$product->save();
$stock = new \Thelia\Model\ProductSaleElements();
$stock->setProduct($product);
$stock->setQuantity($faker->randomNumber(1,50));
$stock->setPromo($faker->randomNumber(0,1));
$stock->save();
$productPrice = new \Thelia\Model\ProductPrice();
$productPrice->setProductSaleElements($stock);
$productPrice->setCurrency($currency);
$productPrice->setPrice($faker->randomFloat(2, 20, 2500));
$productPrice->save();
for($j=0; $j<rand(1, 5); $j++) {
$featureAv = new Thelia\Model\FeatureAv();
$featureAv->setFeature($feature);
$featureAv->setPosition($j);
$featureAv->setTitle($faker->text(20));
$featureAv->setDescription($faker->text(255));
$featureAv->save();
$featureList[$featureId][] = $featureAv->getId();
}
}
for ($i=1; $i <= 5; $i++) {
$product = new \Thelia\Model\Product();
$product->addCategory($jeans);
$product->setTitle($faker->text(20));
$product->setDescription($faker->text(250));
/* $product->setQuantity($faker->randomNumber(1,50));
$product->setPrice($faker->randomFloat(2, 20, 2500));*/
$product->setVisible(1);
$product->setPosition($i);
$product->setRef($faker->text(255));
$product->save();
//categories and products
$productIdList = array();
$categoryIdList = array();
for($i=0; $i<4; $i++) {
$category = new Thelia\Model\Category();
$category->setParent(0);
$category->setVisible(rand(1, 10)>7 ? 0 : 1);
$category->setPosition($i);
$category->setTitle($faker->text(20));
$category->setDescription($faker->text(255));
$stock = new \Thelia\Model\ProductSaleElements();
$stock->setProduct($product);
$stock->setQuantity($faker->randomNumber(1,50));
$stock->setPromo($faker->randomNumber(0,1));
$stock->save();
$category->save();
$categoryIdList[] = $category->getId();
$productPrice = new \Thelia\Model\ProductPrice();
$productPrice->setProductSaleElements($stock);
$productPrice->setCurrency($currency);
$productPrice->setPrice($faker->randomFloat(2, 20, 2500));
$productPrice->save();
for($j=0; $j<rand(0, 4); $j++) {
$subcategory = new Thelia\Model\Category();
$subcategory->setParent($category->getId());
$subcategory->setVisible(rand(1, 10)>7 ? 0 : 1);
$subcategory->setPosition($j);
$subcategory->setTitle($faker->text(20));
$subcategory->setDescription($faker->text(255));
$subcategory->save();
$categoryIdList[] = $subcategory->getId();
for($k=0; $k<rand(1, 5); $k++) {
$product = new Thelia\Model\Product();
$product->setRef($subcategory->getId() . '_' . $k . '_' . $faker->randomNumber(8));
$product->addCategory($subcategory);
$product->setVisible(rand(1, 10)>7 ? 0 : 1);
$product->setPosition($k);
$product->setTitle($faker->text(20));
$product->setDescription($faker->text(255));
$product->save();
$productId = $product->getId();
$productIdList[] = $productId;
//add random accessories - or not
for($l=0; $l<rand(0, 3); $l++) {
$accessory = new Thelia\Model\Accessory();
$accessory->setAccessory($productIdList[array_rand($productIdList, 1)]);
$accessory->setProductId($productId);
$accessory->setPosition($l);
$accessory->save();
}
}
}
for($k=0; $k<rand(1, 5); $k++) {
$product = new Thelia\Model\Product();
$product->setRef($category->getId() . '_' . $k . '_' . $faker->randomNumber(8));
$product->addCategory($category);
$product->setVisible(rand(1, 10)>7 ? 0 : 1);
$product->setPosition($k);
$product->setTitle($faker->text(20));
$product->setDescription($faker->text(255));
$product->save();
$productId = $product->getId();
$productIdList[] = $productId;
//add random accessories
for($l=0; $l<rand(0, 3); $l++) {
$accessory = new Thelia\Model\Accessory();
$accessory->setAccessory($productIdList[array_rand($productIdList, 1)]);
$accessory->setProductId($productId);
$accessory->setPosition($l);
$accessory->save();
}
}
}
//folders and contents
@@ -166,27 +188,6 @@ try {
}
}
//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; $j<rand(1, 5); $j++) {
$featureAv = new Thelia\Model\FeatureAv();
$featureAv->setFeature($feature);
$featureAv->setPosition($j);
$featureAv->setTitle($faker->text(20));
$featureAv->setDescription($faker->text(255));
$featureAv->save();
}
}
$con->commit();
} catch (Exception $e) {
echo "error : ".$e->getMessage()."\n";

View File

@@ -1,8 +1,8 @@
INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`by_default`,`position`,`created_at`,`updated_at`)VALUES
(1, 'Français', 'fr', 'fr_FR', '','1', '1', NOW(), NOW()),
(2, 'English', 'en', 'en_EN', '', '0', '2', NOW(), NOW()),
(3, 'Espanol', 'es', 'es_ES', '', '0', '3', NOW(), NOW()),
(4, 'Italiano', 'it', 'it_IT', '','0', '4', NOW(), NOW());
INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`by_default`,`created_at`,`updated_at`)VALUES
(1, 'Français', 'fr', 'fr_FR', '','1', NOW(), NOW()),
(2, 'English', 'en', 'en_EN', '', '0', NOW(), NOW()),
(3, 'Espanol', 'es', 'es_ES', '', '0', NOW(), NOW()),
(4, 'Italiano', 'it', 'it_IT', '','0', NOW(), NOW());
INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES
('session_config.default', '1', 1, 1, NOW(), NOW()),
@@ -23,11 +23,11 @@ INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES
(3, 'en_US', 'Miss', 'Miss'),
(3, 'fr_FR', 'Mlle', 'Madamemoiselle');
INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate` ,`by_default`, `position` ,`created_at` ,`updated_at`)
INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate` ,`by_default` ,`created_at` ,`updated_at`)
VALUES
(1, 'EUR', '', '1', '1', '1', NOW() , NOW()),
(2, 'USD', '$', '1.26', '0', '2', NOW(), NOW()),
(3, 'GBP', '£', '0.89', '0', '3',NOW(), NOW());
(1, 'EUR', '', '1', '1', NOW() , NOW()),
(2, 'USD', '$', '1.26', '0', NOW(), NOW()),
(3, 'GBP', '£', '0.89', '0', NOW(), NOW());
INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`)
VALUES

View File

@@ -617,8 +617,8 @@ CREATE TABLE `produt_image`
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_product_id` (`product_id`),
CONSTRAINT `fk_product_id`
INDEX `idx_product_image_product_id` (`product_id`),
CONSTRAINT `fk_product_image_product_id`
FOREIGN KEY (`product_id`)
REFERENCES `product` (`id`)
ON UPDATE RESTRICT
@@ -640,8 +640,8 @@ CREATE TABLE `product_document`
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_product_id` (`product_id`),
CONSTRAINT `fk_product_id`
INDEX `idx_product_document_product_id` (`product_id`),
CONSTRAINT `fk_product_document_product_id`
FOREIGN KEY (`product_id`)
REFERENCES `product` (`id`)
ON UPDATE RESTRICT
@@ -844,7 +844,7 @@ DROP TABLE IF EXISTS `accessory`;
CREATE TABLE `accessory`
(
`id` INTEGER NOT NULL,
`id` INTEGER NOT NULL AUTO_INCREMENT,
`product_id` INTEGER NOT NULL,
`accessory` INTEGER NOT NULL,
`position` INTEGER NOT NULL,
@@ -1332,8 +1332,8 @@ CREATE TABLE `category_image`
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_category_id` (`category_id`),
CONSTRAINT `fk_category_id`
INDEX `idx_category_image_category_id` (`category_id`),
CONSTRAINT `fk_category_image_category_id`
FOREIGN KEY (`category_id`)
REFERENCES `category` (`id`)
ON UPDATE RESTRICT
@@ -1355,8 +1355,8 @@ CREATE TABLE `folder_image`
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_folder_id` (`folder_id`),
CONSTRAINT `fk_folder_id`
INDEX `idx_folder_image_folder_id` (`folder_id`),
CONSTRAINT `fk_folder_image_folder_id`
FOREIGN KEY (`folder_id`)
REFERENCES `folder` (`id`)
ON UPDATE RESTRICT
@@ -1378,8 +1378,8 @@ CREATE TABLE `content_image`
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_content_id` (`content_id`),
CONSTRAINT `fk_content_id`
INDEX `idx_content_image_content_id` (`content_id`),
CONSTRAINT `fk_content_image_content_id`
FOREIGN KEY (`content_id`)
REFERENCES `content` (`id`)
ON UPDATE RESTRICT
@@ -1401,8 +1401,8 @@ CREATE TABLE `category_document`
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_category_id` (`category_id`),
CONSTRAINT `fk_category_id`
INDEX `idx_category_document_category_id` (`category_id`),
CONSTRAINT `fk_catgory_document_category_id`
FOREIGN KEY (`category_id`)
REFERENCES `category` (`id`)
ON UPDATE RESTRICT
@@ -1424,8 +1424,8 @@ CREATE TABLE `content_document`
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_content_id` (`content_id`),
CONSTRAINT `fk_content_id`
INDEX `idx_content_document_content_id` (`content_id`),
CONSTRAINT `fk_content_document_content_id`
FOREIGN KEY (`content_id`)
REFERENCES `content` (`id`)
ON UPDATE RESTRICT
@@ -1447,8 +1447,8 @@ CREATE TABLE `folder_document`
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_folder_id` (`folder_id`),
CONSTRAINT `fk_folder_id`
INDEX `idx_folder_document_folder_id` (`folder_id`),
CONSTRAINT `fk_folder_document_folder_id`
FOREIGN KEY (`folder_id`)
REFERENCES `folder` (`id`)
ON UPDATE RESTRICT