import brand successfully
This commit is contained in:
@@ -51,15 +51,46 @@ try {
|
|||||||
|
|
||||||
$categories = createCategories();
|
$categories = createCategories();
|
||||||
createColors();
|
createColors();
|
||||||
|
createBrand();
|
||||||
$con->commit();
|
$con->commit();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo "error : ".$e->getMessage()."\n";
|
echo "error : ".$e->getMessage()."\n";
|
||||||
$con->rollBack();
|
$con->rollBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
function createCategories()
|
function createCategories()
|
||||||
{
|
{
|
||||||
|
echo "start creating categories\n";
|
||||||
$categories = array();
|
$categories = array();
|
||||||
if (($handle = fopen(THELIA_ROOT . '/install/import/categories.csv', "r")) !== FALSE) {
|
if (($handle = fopen(THELIA_ROOT . '/install/import/categories.csv', "r")) !== FALSE) {
|
||||||
$row=0;
|
$row=0;
|
||||||
@@ -80,12 +111,13 @@ function createCategories()
|
|||||||
}
|
}
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
}
|
||||||
|
echo "categories created successfully\n";
|
||||||
return $categories;
|
return $categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createColors()
|
function createColors()
|
||||||
{
|
{
|
||||||
|
echo "start creating colors attributes\n";
|
||||||
if (($handle = fopen(THELIA_ROOT . '/install/import/colors.csv', "r")) !== FALSE) {
|
if (($handle = fopen(THELIA_ROOT . '/install/import/colors.csv', "r")) !== FALSE) {
|
||||||
$row=0;
|
$row=0;
|
||||||
$attribute = new \Thelia\Model\Attribute();
|
$attribute = new \Thelia\Model\Attribute();
|
||||||
@@ -111,7 +143,7 @@ function createColors()
|
|||||||
$attribute->save();
|
$attribute->save();
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
}
|
||||||
|
echo "colors attributes created with success\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearTables()
|
function clearTables()
|
||||||
|
|||||||
7
install/import/brand.csv
Normal file
7
install/import/brand.csv
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
"MILAN"
|
||||||
|
"MAGIS"
|
||||||
|
"OXYO"
|
||||||
|
"OFFUS"
|
||||||
|
"PLINK"
|
||||||
|
"PARRY"
|
||||||
|
"TOKO"
|
||||||
|
Reference in New Issue
Block a user