Merge branch 'master' of github.com:thelia/thelia

This commit is contained in:
Etienne Roudeix
2013-09-19 15:12:37 +02:00
124 changed files with 1907 additions and 26 deletions

View File

@@ -405,17 +405,26 @@
<!-- Shipping zones routes management -->
<route id="admin.configuration.shipping-zones.default" path="/admin/configuration/shipping-zones">
<route id="admin.configuration.shipping-zones.default" path="/admin/configuration/shipping_zones">
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::indexAction</default>
</route>
<route id="admin.configuration.shipping-zones.create" path="/admin/configuration/shipping-zones/create">
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::createAction</default>
<route id="admin.configuration.shipping-zones.update.view" path="/admin/configuration/shipping_zones/update/{shipping_zones_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::updateAction</default>
<requirement key="shipping_zones_id">\d+</requirement>
</route>
<route id="admin.configuration.shipping-zones.update.view" path="/admin/configuration/shipping-zones/update/{shipping_zones_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::updateAction</default>
<requirement key="country_id">\d+</requirement>
<!-- end shipping routes management -->
<!-- Shipping zones routes management -->
<route id="admin.configuration.shipping-configuration.default" path="/admin/configuration/shipping_configuration">
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::indexAction</default>
</route>
<route id="admin.configuration.shipping-configuration.update.view" path="/admin/configuration/shipping_configuration/update/{shipping_configuration_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::updateAction</default>
<requirement key="shipping_configuration_id">\d+</requirement>
</route>
<!-- end shipping routes management -->
@@ -478,6 +487,15 @@
<!-- end feature and feature routes management -->
<!-- Modules rule management -->
<route id="admin.module" path="/admin/modules">
<default key="_controller">Thelia\Controller\Admin\ModuleController::indexAction</default>
</route>
<!-- end Modules rule management -->
<!-- The default route, to display a template -->
<route id="admin.processTemplate" path="/admin/{template}">

View File

@@ -0,0 +1,46 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
/**
* Class ModuleController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ModuleController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth("admin.module.view")) return $response;
return $this->render("modules", array("display_module" => 20));
}
public function updateAction($module_id)
{
return $this->render("module-edit", array(
"module_id" => $module_id
));
}
}

View File

@@ -0,0 +1,46 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
/**
* Class ShippingConfigurationController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ShippingConfigurationController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response;
return $this->render("shipping-configuration", array("display_shipping_configuration" => 20));
}
public function updateAction($shipping_configuration_id)
{
return $this->render("shipping-configuration-edit", array(
"shipping_configuration_id" => $shipping_configuration_id
));
}
}

View File

@@ -24,7 +24,7 @@
namespace Thelia\Controller\Admin;
/**
* Class FolderController
* Class ShippingZoneController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/

View File

@@ -93,7 +93,8 @@ class Image extends BaseI18nLoop
new EnumType($this->possible_sources)
)
),
Argument::createIntTypeArgument('source_id')
Argument::createIntTypeArgument('source_id'),
Argument::createBooleanTypeArgument('force_return', true)
);
// Add possible image sources

379
install/import.php Normal file
View File

@@ -0,0 +1,379 @@
<?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/>. */
/* */
/*************************************************************************************/
use Thelia\Constraint\ConstraintFactory;
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
use Thelia\Constraint\Rule\AvailableForXArticlesManager;
use Thelia\Constraint\Rule\Operators;
use Thelia\Coupon\CouponRuleCollection;
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();
$stmt = $con->prepare("SET foreign_key_checks = 1");
$stmt->execute();
$categories = createCategories();
$color = createColors();
$brand = createBrand();
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();
$at = new Thelia\Model\AttributeTemplate();
$at
->setTemplate($template)
->setAttribute($color)
->save();
$ft = new Thelia\Model\FeatureTemplate();
$ft
->setTemplate($template)
->setFeature($brand)
->save();
echo "end creating templates\n";
createProduct($faker, $categories, $template, $color, $brand);
$con->commit();
} catch (Exception $e) {
echo "error : ".$e->getMessage()."\n";
$con->rollBack();
}
function createProduct($faker, $categories, $template, $attribute, $feature)
{
echo "start creating products\n";
$fileSystem = new \Symfony\Component\Filesystem\Filesystem();
if (($handle = fopen(THELIA_ROOT . '/install/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();
$productCategories = $product->getProductCategories()->getFirst();
$productCategories->setDefaultCategory(true)
->save();
// 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();
$fileSystem->copy(THELIA_ROOT . 'install/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, 100,10000));
$stock->save();
$productPrice = new \Thelia\Model\ProductPrice();
$productPrice->setProductSaleElements($stock);
$productPrice->setCurrencyId(1);
$productPrice->setPrice($data[8]);
$productPrice->setPromoPrice($data[9]);
$productPrice->save();
$attributeAv = \Thelia\Model\AttributeAvI18nQuery::create()
->filterByLocale('en_US')
->filterByTitle($pse)
->findOne();
$attributeCombination = new \Thelia\Model\AttributeCombination();
$attributeCombination
->setAttributeId($attribute->getId())
->setAttributeAvId($attributeAv->getId())
->setProductSaleElements($stock)
->save();
}
$brand = $data[11];
$featurAv = \Thelia\Model\FeatureAvI18nQuery::create()
->filterByLocale('en_US')
->filterByTitle($brand)
->findOne();
$featureProduct = new Thelia\Model\FeatureProduct();
$featureProduct->setProduct($product)
->setFeatureId($feature->getId())
->setFeatureAvId($featurAv->getId())
->save()
;
}
}
echo "end creating products\n";
}
function createBrand()
{
echo "start creating brands feature\n";
if (($handle = fopen(THELIA_ROOT . '/install/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();
fclose($handle);
}
echo "brands feature created successfully\n";
return $feature;
}
function createCategories()
{
echo "start creating categories\n";
$categories = array();
if (($handle = fopen(THELIA_ROOT . '/install/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();
$categories[trim($data[1])] = $category;
}
fclose($handle);
}
echo "categories created successfully\n";
return $categories;
}
function createColors()
{
echo "start creating colors attributes\n";
if (($handle = fopen(THELIA_ROOT . '/install/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();
fclose($handle);
}
echo "colors attributes created with success\n";
return $attribute;
}
function clearTables()
{
$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();
$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();
}

7
install/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
install/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

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

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