refactor category position and product_category assignment
This commit is contained in:
@@ -111,19 +111,20 @@ function createProduct($faker, $categories, $template, $attribute, $feature)
|
|||||||
$product->addCategory($categories[$productCategory]);
|
$product->addCategory($categories[$productCategory]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
$productCategories = $product->getProductCategories();
|
$productCategories = $product->getProductCategories();
|
||||||
$collection = new \Propel\Runtime\Collection\Collection();
|
$collection = new \Propel\Runtime\Collection\Collection();
|
||||||
foreach($productCategories as $i => $productCategory) {
|
$i=0;
|
||||||
|
foreach($productCategories as $productCategory) {
|
||||||
if($i == 0) {
|
if($i == 0) {
|
||||||
$collection->append($productCategory->setDefaultCategory(1));
|
$collection->append($productCategory->setDefaultCategory(true));
|
||||||
} else {
|
} else {
|
||||||
$collection->append($productCategory);
|
$collection->append($productCategory);
|
||||||
}
|
}
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$product->setProductCategories($collection);
|
$product->setProductCategories($collection);*/
|
||||||
|
|
||||||
$product
|
$product
|
||||||
->setLocale('en_US')
|
->setLocale('en_US')
|
||||||
@@ -138,6 +139,13 @@ function createProduct($faker, $categories, $template, $attribute, $feature)
|
|||||||
->setPostscriptum($data[7])
|
->setPostscriptum($data[7])
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
$productCategories = $product->getProductCategories()->getFirst();
|
||||||
|
$productCategories->setDefaultCategory(true)
|
||||||
|
->save();
|
||||||
|
|
||||||
|
// Set the position
|
||||||
|
$product->setPosition($product->getNextPosition())->save();
|
||||||
|
|
||||||
$images = explode(';', $data[10]);
|
$images = explode(';', $data[10]);
|
||||||
|
|
||||||
foreach ($images as $image) {
|
foreach ($images as $image) {
|
||||||
@@ -182,7 +190,6 @@ function createProduct($faker, $categories, $template, $attribute, $feature)
|
|||||||
->filterByTitle($pse)
|
->filterByTitle($pse)
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
var_dump($attributeAv->getTitle());
|
|
||||||
$attributeCombination = new \Thelia\Model\AttributeCombination();
|
$attributeCombination = new \Thelia\Model\AttributeCombination();
|
||||||
$attributeCombination
|
$attributeCombination
|
||||||
->setAttributeId($attribute->getId())
|
->setAttributeId($attribute->getId())
|
||||||
|
|||||||
Reference in New Issue
Block a user