Attributes can be set in products now
This commit is contained in:
@@ -35,6 +35,8 @@ class ProductController extends mfBaseController {
|
||||
$this->redirect("Product");
|
||||
}
|
||||
|
||||
//var_dump($product->attributes);exit;
|
||||
|
||||
$this->layout()->set("product", $product);
|
||||
|
||||
return $this->addAction();
|
||||
@@ -49,7 +51,7 @@ class ProductController extends mfBaseController {
|
||||
$product = new Product($id);
|
||||
if(!$product->id) {
|
||||
$this->layout()->setFlash("Produkt nicht gefunden", "error");
|
||||
$this->redirect("Produkt");
|
||||
$this->redirect("Product");
|
||||
}
|
||||
} else {
|
||||
$id = false;
|
||||
@@ -79,10 +81,10 @@ class ProductController extends mfBaseController {
|
||||
$data['productgroup_id'] = null;
|
||||
}
|
||||
|
||||
$data['edit_by'] = 1;
|
||||
$data['edit_by'] = $this->me->id;
|
||||
|
||||
if($mode == "add") {
|
||||
$data['create_by'] = 1;
|
||||
$data['create_by'] = $this->me->id;
|
||||
$product = ProductModel::create($data);
|
||||
} else {
|
||||
$product->update($data);
|
||||
@@ -141,6 +143,22 @@ class ProductController extends mfBaseController {
|
||||
$product->save();
|
||||
}
|
||||
|
||||
if(is_array($r->attributes) && count($r->attributes)) {
|
||||
foreach($r->attributes as $pta_id => $attribute_value) {
|
||||
$attrib = ProductAttributeModel::getFirst(['product_id' => $new_id, 'producttechattribute_id' => $pta_id]);
|
||||
if(!$attrib) {
|
||||
$attrib = ProductAttributeModel::create([
|
||||
'product_id' => $new_id,
|
||||
'producttechattribute_id' => $pta_id,
|
||||
]);
|
||||
//var_dump($attrib);exit;
|
||||
}
|
||||
$attrib->value = $attribute_value;
|
||||
$attrib->edit_by = $this->me->id;
|
||||
$attrib->save();
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Produkt erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Product", "Edit", ['id' => $new_id]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user