I only know that getProductUrl() ?> is calling "http://b2b.com/product1/" But how to call a dynamic URL key in the /product/view.phtml, so then in the URL structure only the domain is changed from b2b.com to b2c.com but the product key will stay the same according to which product is being viewed?

  • Your question is not clear. Try rephrasing it or it will be closed.
    – SR_Magento
    Jan 28, 2015 at 22:32

3 Answers 3


If the site is setup with the proper store scopes, native magento will handle this for you through the


function. You should confirm the base_url is set properly for both store scopes.


I have no idea if this will work for you, but hopefully this will get you in the right direction.

To get the URL key you should use $product->getUrlPath(); If the url is http:://b2b.com/product1 it will give you 'product1'


Okay, I found a solution that is exactly what I want to achieve:

<a href="http://google.com/<?php $_product = Mage::getModel('catalog/product')->load($_product->getId()) ?><?php echo $_product->getUrlKey(); ?>">ProductName</a>

Then the URL link will be shown as google.com/ProductName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.