diff --git a/install/import.php b/install/import.php index 6158f973b..a18c088a3 100644 --- a/install/import.php +++ b/install/import.php @@ -48,9 +48,9 @@ try { $stmt = $con->prepare("SET foreign_key_checks = 1"); $stmt->execute(); - - $categories = createCategories(); + $categories = createCategories(); + createColors(); $con->commit(); } catch (Exception $e) { @@ -84,6 +84,36 @@ function createCategories() return $categories; } +function createColors() +{ + 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); + } + +} + function clearTables() { $productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create() diff --git a/install/import/colors.csv b/install/import/colors.csv new file mode 100644 index 000000000..9b5ebcb6a --- /dev/null +++ b/install/import/colors.csv @@ -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"