I have a big doubt in forming url for products. Currently url is formed by using the name attribute. I want to change this to sku_id(attribute) of the products. For this where i need to change?
2 Answers
You can use product sku value in product "URL Key" field.
Or
You can use an extension for custom product URL. Its free and easy to use.
-
Thanks. I am new to magento and i don't know where to set sku_id for url changes. please refer me the file path for this changes.– RasheedCommented Apr 3, 2017 at 8:00
-
No changes in any file. You can change from admin panel: admin -> catalog -> manage products -> Edit product or Add new product -> (in General tab ) URL key field. In URL key write "sku" value. Commented Apr 3, 2017 at 9:45
-
I have more than 500 products, and product name as URL key for all products.– RasheedCommented Apr 3, 2017 at 9:52
-
-
Please check and follow like this : stackoverflow.com/questions/23987445/… Commented Apr 3, 2017 at 9:56
If you want to have the
Sku
in products url instead ofname
product, you just have to put your sku in the url key catalog>product manager>add product>url key
.If you want to add it in url, you can follow this:
Use an Event Observer catalog_product_save_before
config.xml
<global>
<events>
<catalog_product_save_before>
<observers>
<stockalert>
<type>singleton</type>
<class>yourmodel/observer</class>
<method>autoupdateurlKey</method>
</stockalert>
</observers>
</catalog_product_save_before>
</events>
</global>
Observer:
public function autoupdateurlKey($observer)
{
$product=$observer->getEvent()->getProduct();
$oldUrlKey=$product->getOrigData('url_key');
$Sku=$product->getSku();
$TypeId=$product->getTypeId();
// put yourlogic
$product->getData('url_key',$YourNewUrl);
return $this;
}
seo
....