Question

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.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top