Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://myhost.com/category-name/brand-name/product-name
- class Vendor_Module_Model_Catalog_Product_Url extends Mage_Catalog_Model_Product_Url
- {
- /**
- * Format Key for URL
- *
- * @param string $str
- * @return string
- */
- public function formatUrlKey($str)
- {
- // added '/' character
- $urlKey = preg_replace('#[^0-9a-z/.]+#i', '-', Mage::helper('catalog/product_url')->format($str));
- $urlKey = strtolower($urlKey);
- $urlKey = trim($urlKey, '-');
- return $urlKey;
- }
- }
- class Vendor_Module_Model_Catalog_Product_Attribute_Backend_Urlkey
- extends Mage_Catalog_Model_Product_Attribute_Backend_Urlkey
- {
- /**
- * Before save
- *
- * @param Varien_Object $object
- * @return Mage_Catalog_Model_Resource_Product_Attribute_Backend_Urlkey
- * @overridden
- */
- public function beforeSave($object)
- {
- $attributeName = $this->getAttribute()->getName();
- $urlKey = $object->getData($attributeName);
- if ($urlKey == '') {
- $urlKey = "{$object->getBrandName()}/{$object->getName()}";
- }
- $object->setData($attributeName, $object->formatUrlKey($urlKey));
- return $this;
- }
- }
Add Comment
Please, Sign In to add comment