import colors attributes
This commit is contained in:
@@ -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()
|
||||
|
||||
13
install/import/colors.csv
Normal file
13
install/import/colors.csv
Normal 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"
|
||||
|
Reference in New Issue
Block a user