Manufacturer in product url key
-
31-10-2019 - |
Pergunta
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.
Nenhuma solução correta
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange