Added new brands to demo import
@@ -45,7 +45,7 @@ try {
|
|||||||
|
|
||||||
$categories = createCategories($con);
|
$categories = createCategories($con);
|
||||||
$color = createColors($con);
|
$color = createColors($con);
|
||||||
$brand = createBrand($con);
|
$brands = createBrands($con);
|
||||||
|
|
||||||
echo "creating templates\n";
|
echo "creating templates\n";
|
||||||
$template = new \Thelia\Model\Template();
|
$template = new \Thelia\Model\Template();
|
||||||
@@ -63,15 +63,16 @@ try {
|
|||||||
->setAttribute($color)
|
->setAttribute($color)
|
||||||
->save($con);
|
->save($con);
|
||||||
|
|
||||||
|
/*
|
||||||
$ft = new Thelia\Model\FeatureTemplate();
|
$ft = new Thelia\Model\FeatureTemplate();
|
||||||
|
|
||||||
$ft
|
$ft
|
||||||
->setTemplate($template)
|
->setTemplate($template)
|
||||||
->setFeature($brand)
|
->setFeature($brand)
|
||||||
->save($con);
|
->save($con);
|
||||||
|
*/
|
||||||
echo "end creating templates\n";
|
echo "end creating templates\n";
|
||||||
|
|
||||||
createProduct($faker, $categories, $template, $color, $brand, $con);
|
createProduct($faker, $categories, $brands, $template, $color, null, $con);
|
||||||
|
|
||||||
$con->commit();
|
$con->commit();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -79,7 +80,7 @@ try {
|
|||||||
$con->rollBack();
|
$con->rollBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createProduct($faker, $categories, $template, $attribute, $feature, $con)
|
function createProduct($faker, $categories, $brands, $template, $attribute, $feature, $con)
|
||||||
{
|
{
|
||||||
echo "start creating products\n";
|
echo "start creating products\n";
|
||||||
$fileSystem = new \Symfony\Component\Filesystem\Filesystem();
|
$fileSystem = new \Symfony\Component\Filesystem\Filesystem();
|
||||||
@@ -104,6 +105,11 @@ function createProduct($faker, $categories, $template, $attribute, $feature, $co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$brand = $data[11];
|
||||||
|
if (array_key_exists($brand, $brands)) {
|
||||||
|
$product->setBrand($brands[$brand]);
|
||||||
|
}
|
||||||
|
|
||||||
$product
|
$product
|
||||||
->setLocale('en_US')
|
->setLocale('en_US')
|
||||||
->setTitle($data[1])
|
->setTitle($data[1])
|
||||||
@@ -178,6 +184,7 @@ function createProduct($faker, $categories, $template, $attribute, $feature, $co
|
|||||||
$productSaleElements = $product->getProductSaleElementss()->getFirst();
|
$productSaleElements = $product->getProductSaleElementss()->getFirst();
|
||||||
$productSaleElements->setIsDefault(1)->save($con);
|
$productSaleElements->setIsDefault(1)->save($con);
|
||||||
|
|
||||||
|
/*
|
||||||
$brand = $data[11];
|
$brand = $data[11];
|
||||||
$featurAv = \Thelia\Model\FeatureAvI18nQuery::create()
|
$featurAv = \Thelia\Model\FeatureAvI18nQuery::create()
|
||||||
->filterByLocale('en_US')
|
->filterByLocale('en_US')
|
||||||
@@ -190,12 +197,14 @@ function createProduct($faker, $categories, $template, $attribute, $feature, $co
|
|||||||
->setFeatureAvId($featurAv->getId())
|
->setFeatureAvId($featurAv->getId())
|
||||||
->save($con)
|
->save($con)
|
||||||
;
|
;
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "end creating products\n";
|
echo "end creating products\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
function createBrand($con)
|
function createBrand($con)
|
||||||
{
|
{
|
||||||
echo "start creating brands feature\n";
|
echo "start creating brands feature\n";
|
||||||
@@ -227,6 +236,64 @@ function createBrand($con)
|
|||||||
|
|
||||||
return $feature;
|
return $feature;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function createBrands($con)
|
||||||
|
{
|
||||||
|
echo "start creating brands\n";
|
||||||
|
|
||||||
|
$fileSystem = new \Symfony\Component\Filesystem\Filesystem();
|
||||||
|
|
||||||
|
$brands = array();
|
||||||
|
if (($handle = fopen(THELIA_ROOT . '/setup/import/brand.csv', "r")) !== FALSE) {
|
||||||
|
$row=0;
|
||||||
|
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
|
||||||
|
$row++;
|
||||||
|
if ($row == 1) continue;
|
||||||
|
|
||||||
|
$brand = new \Thelia\Model\Brand();
|
||||||
|
|
||||||
|
$brand
|
||||||
|
->setVisible(1)
|
||||||
|
->setPosition($row-1)
|
||||||
|
->setLocale('fr_FR')
|
||||||
|
->setTitle(trim($data[0]))
|
||||||
|
->setLocale('en_US')
|
||||||
|
->setTitle(trim($data[0]))
|
||||||
|
->save($con);
|
||||||
|
|
||||||
|
$brands[trim($data[0])] = $brand;
|
||||||
|
|
||||||
|
$images = explode(';', $data[1]);
|
||||||
|
$logoId = null;
|
||||||
|
foreach ($images as $image) {
|
||||||
|
$image = trim($image);
|
||||||
|
if(empty($image)) continue;
|
||||||
|
$brandImage = new \Thelia\Model\BrandImage();
|
||||||
|
$brandImage
|
||||||
|
->setBrandId($brand->getId())
|
||||||
|
->setFile($image)
|
||||||
|
->save($con);
|
||||||
|
if ($logoId === null) {
|
||||||
|
$logoId = $brandImage->getId();
|
||||||
|
}
|
||||||
|
$fileSystem->copy(THELIA_ROOT . 'setup/import/images/'.$image, THELIA_ROOT . 'local/media/images/brand/'.$image, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($logoId !== null){
|
||||||
|
$brand->setLogoImageId($logoId);
|
||||||
|
$brand->save($con);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
|
}
|
||||||
|
echo "brands created successfully\n";
|
||||||
|
|
||||||
|
return $brands;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function createCategories($con)
|
function createCategories($con)
|
||||||
{
|
{
|
||||||
@@ -291,6 +358,8 @@ function createColors($con)
|
|||||||
|
|
||||||
function clearTables($con)
|
function clearTables($con)
|
||||||
{
|
{
|
||||||
|
echo "Clearing tables\n";
|
||||||
|
|
||||||
$productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create()
|
$productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create()
|
||||||
->find($con);
|
->find($con);
|
||||||
$productAssociatedContent->delete($con);
|
$productAssociatedContent->delete($con);
|
||||||
@@ -368,4 +437,7 @@ function clearTables($con)
|
|||||||
$productPrice->delete($con);
|
$productPrice->delete($con);
|
||||||
|
|
||||||
\Thelia\Model\ProductImageQuery::create()->find($con)->delete($con);
|
\Thelia\Model\ProductImageQuery::create()->find($con)->delete($con);
|
||||||
|
|
||||||
|
echo "Tables cleared with success\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
"MILAN"
|
"NAME";"LOGO"
|
||||||
"MAGIS"
|
"MILAN";"BRAND-1.png"
|
||||||
"OXYO"
|
"MAGIS";"BRAND-2.png"
|
||||||
"OFFUS"
|
"OXYO";"BRAND-3.png"
|
||||||
"PLINK"
|
"OFFUS";"BRAND-4.png"
|
||||||
"PARRY"
|
"PLINK";"BRAND-5.png"
|
||||||
"TOKO"
|
"PARRY";"BRAND-6.png"
|
||||||
|
"TOKO";"BRAND-7.png"
|
||||||
|
|||||||
|
BIN
setup/import/images/BRAND-1.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
setup/import/images/BRAND-2.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
setup/import/images/BRAND-3.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
setup/import/images/BRAND-4.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
setup/import/images/BRAND-5.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
setup/import/images/BRAND-6.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
setup/import/images/BRAND-7.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |