I kept looking for days to find a way to fill the product title (in the backend product add/edit form) field automatically based on values that i choose on different custom attributes.
-
1The question is a bit unclear. Can you provide an example?– Marius ♦Commented May 27, 2014 at 6:38
-
Yes, for example i have a tire as a product and i want to have its name generated as "Width/AspectRatio"R"RimSize Brand Model ..." where Width, AspectRatio, Rimsize, Brand and Model are Extra product attributes. So when i save the product its name gets filled with the attributes value that i have set.– aurel.dragutCommented May 27, 2014 at 7:04
Add a comment
|
1 Answer
You can observe the event catalog_product_save_before
and construct the name based on the attributes you need.
Here is a small example on how the observer method could look.
public function generateName($observer) {
$product = $observer->getEvent()->getProduct();
$newName = $product->getWidth(). ' - '.$product->getAspectRatio().' - '....//all attributes you need
$product->setName($newName);
return $this;
}
This could work if when you save the product from the backend, but I don't think it will work if you import products.
-
Yeah that would be a good question, probably you have to save again every imported product or maybe "update attributes" might work. Commented May 27, 2014 at 7:37