1

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.

2
  • 1
    The 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. Commented May 27, 2014 at 7:04

1 Answer 1

1

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.

1
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.