2

given a product page, i need to retrieve the product url for another store. I'm trying this solution:

 Mage::getUrl('', array(
        '_current' => true,
        '_use_rewrite' => true,
        '_secure' => true,
        '_store' => 3,
        '_store_to_url' => true
    ));

but the result is that just the base url is changed, while the url key is the same. The link of course is broken. i can't use the url_rewrite model because if there is no record for a product it just returns the base url. Any idea?

thanks

3

Since you don't have access to URLs from the URL rewrites you'll need to add a setStoreId() when loading the product. Note, it's faster to have a URL key and query it instead of loading up the entire product Model.

$productId = 1234; 
$product = Mage::getModel('catalog/product')
            ->setStoreId(2) // set your store ID
            ->load($productId);

zend_debug::dump($product->getProductUrl());

Further reading:

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.