I am trying to have all product url keys automatically generated this way:
site.com/manufacturer-productname-sku.html
I managed to add the SKU adding to the file /app/code/local/Mage/Catalog/Model/Product/Attribute/Backend/Urlkey.php:
public function beforeSave($object)
{
$attributeName = $this->getAttribute()->getName();
$urlKey = $object->getData($attributeName);
if ($urlKey === false) {
return $this;
}
if ($urlKey == '') {
$urlKey = $object->getName().'-'.$object->getSku();
}
$object->setData($attributeName, $object->formatUrlKey($urlKey));
return $this;
}
Adding getManufacturer()
or getData('manufacturer')
are not working, so the $_product->getAttributeText
Any suggestion?
It would also be better if the SKU kept the capital letters, but that's an option.
Best Answer
You can do this by using catalog_product_save_befoe event .Here details below
code
MageStack_24869.xml
of app\etc\modules\And
config.xml
pathapp\code\local\MageStack\24869\etc\
and code isAlso
Observer.php
code path (app\code\local\MageStack\24869\Model
)Also you can do using below code
https://stackoverflow.com/questions/23987445/how-to-customize-product-url