Add custom product attribute to URL product viewCustom URL rewrite for reviews in MagentoMagento EE Create Custom Redirect for old URLAutomatic URL rewrite after deleting a productHow Can I Customize Magento Default URL (Product URL and Category URL)Custom module url rewriteHow to delete and regenerate URL rewrites in Magento 2?Magento 2 : Product URL rewrite issueShop by Brand/Manufacturer custom URL in M1How to add a custom attribute value to product url in Magento 2Url Rewrite Issue in product duplication
If Melisandre foresaw another character closing blue eyes, why did she follow Stannis?
Is balancing necessary on a full-wheel change?
If 1. e4 c6 is considered as a sound defense for black, why is 1. c3 so rare?
Why is Arya visibly scared in the library in S8E3?
Packet sniffer for MacOS Mojave and above
Why is Thanos so tough at the beginning of "Avengers: Endgame"?
What is the word which sounds like "shtrass"?
Floor tile layout process?
Binary Numbers Magic Trick
How did Captain America use this power?
Entropy as a function of temperature: is temperature well defined?
Power LED from 3.3V Power Pin without Resistor
Copy line and insert it in a new position with sed or awk
LT Spice Voltage Output
Can PCs use nonmagical armor and weapons looted from monsters?
Historically, were women trained for obligatory wars? Or did they serve some other military function?
Can a cyclic Amine form an Amide?
Any examples of headwear for races with animal ears?
Password expiration with Password manager
Would "lab meat" be able to feed a much larger global population
How to implement float hashing with approximate equality
Unexpected email from Yorkshire Bank
How to get SEEK accessing converted ID via view
How did Arya get back her dagger from Sansa?
Add custom product attribute to URL product view
Custom URL rewrite for reviews in MagentoMagento EE Create Custom Redirect for old URLAutomatic URL rewrite after deleting a productHow Can I Customize Magento Default URL (Product URL and Category URL)Custom module url rewriteHow to delete and regenerate URL rewrites in Magento 2?Magento 2 : Product URL rewrite issueShop by Brand/Manufacturer custom URL in M1How to add a custom attribute value to product url in Magento 2Url Rewrite Issue in product duplication
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have created an EAV entity (that represents the brand) which can be associated to a product as an attribute.
Now, I would like to add the name of the brand to the product view URL.
I would like something like this:
http://myhost.com/category-name/brand-name/product-name
Is there a way to extend the url rewrite for products view?
url-rewrite product-view ce-1.9.2.2 product-urls
add a comment |
I have created an EAV entity (that represents the brand) which can be associated to a product as an attribute.
Now, I would like to add the name of the brand to the product view URL.
I would like something like this:
http://myhost.com/category-name/brand-name/product-name
Is there a way to extend the url rewrite for products view?
url-rewrite product-view ce-1.9.2.2 product-urls
add a comment |
I have created an EAV entity (that represents the brand) which can be associated to a product as an attribute.
Now, I would like to add the name of the brand to the product view URL.
I would like something like this:
http://myhost.com/category-name/brand-name/product-name
Is there a way to extend the url rewrite for products view?
url-rewrite product-view ce-1.9.2.2 product-urls
I have created an EAV entity (that represents the brand) which can be associated to a product as an attribute.
Now, I would like to add the name of the brand to the product view URL.
I would like something like this:
http://myhost.com/category-name/brand-name/product-name
Is there a way to extend the url rewrite for products view?
url-rewrite product-view ce-1.9.2.2 product-urls
url-rewrite product-view ce-1.9.2.2 product-urls
asked Feb 25 '16 at 17:43
gianis6gianis6
7351435
7351435
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In order to create url key with "/" sign you need to override Mage_Catalog_Model_Product_Url
's formatUrlKey()
method.
You can do it like so:
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;
You can override beforeSave()
method of the Backend Model of Catalog Product Urlkey attribute as following:
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;
Now while product is being saved, if url key empty it will automatically create an 'brand-name/name' like url. If it comes to category name it is a matter of magento configuration to or not to add category name at the begining of URL address.
Alternatively check out this free extension, it does exactly what you require:
https://www.magentocommerce.com/magento-connect/custom-product-urls-seo.html
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103529%2fadd-custom-product-attribute-to-url-product-view%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In order to create url key with "/" sign you need to override Mage_Catalog_Model_Product_Url
's formatUrlKey()
method.
You can do it like so:
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;
You can override beforeSave()
method of the Backend Model of Catalog Product Urlkey attribute as following:
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;
Now while product is being saved, if url key empty it will automatically create an 'brand-name/name' like url. If it comes to category name it is a matter of magento configuration to or not to add category name at the begining of URL address.
Alternatively check out this free extension, it does exactly what you require:
https://www.magentocommerce.com/magento-connect/custom-product-urls-seo.html
add a comment |
In order to create url key with "/" sign you need to override Mage_Catalog_Model_Product_Url
's formatUrlKey()
method.
You can do it like so:
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;
You can override beforeSave()
method of the Backend Model of Catalog Product Urlkey attribute as following:
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;
Now while product is being saved, if url key empty it will automatically create an 'brand-name/name' like url. If it comes to category name it is a matter of magento configuration to or not to add category name at the begining of URL address.
Alternatively check out this free extension, it does exactly what you require:
https://www.magentocommerce.com/magento-connect/custom-product-urls-seo.html
add a comment |
In order to create url key with "/" sign you need to override Mage_Catalog_Model_Product_Url
's formatUrlKey()
method.
You can do it like so:
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;
You can override beforeSave()
method of the Backend Model of Catalog Product Urlkey attribute as following:
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;
Now while product is being saved, if url key empty it will automatically create an 'brand-name/name' like url. If it comes to category name it is a matter of magento configuration to or not to add category name at the begining of URL address.
Alternatively check out this free extension, it does exactly what you require:
https://www.magentocommerce.com/magento-connect/custom-product-urls-seo.html
In order to create url key with "/" sign you need to override Mage_Catalog_Model_Product_Url
's formatUrlKey()
method.
You can do it like so:
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;
You can override beforeSave()
method of the Backend Model of Catalog Product Urlkey attribute as following:
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;
Now while product is being saved, if url key empty it will automatically create an 'brand-name/name' like url. If it comes to category name it is a matter of magento configuration to or not to add category name at the begining of URL address.
Alternatively check out this free extension, it does exactly what you require:
https://www.magentocommerce.com/magento-connect/custom-product-urls-seo.html
edited Jun 17 '16 at 7:52
7ochem
5,88493770
5,88493770
answered Jun 17 '16 at 7:41
Marcin KlauzaMarcin Klauza
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103529%2fadd-custom-product-attribute-to-url-product-view%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown