Using the SOAP API, how can I get URL for the product (when requesting from catalog_product.info) that will always work?

Using url_key and appending ".html" is not good enough because in many stores that won't work.

So at the moment I have this:

$url = $shop_url . '/catalog/product/view/id/' . $product_id;

The $shop_url being the domain eg http://www.store.com.

The only issue with that is that the product may not be visible on all stores.... E.g. a single magento may have more than one storefront, each with a different url and each showing a subset of products... so thats hard.

Any ideas?

EDIT: I will also accept an answer which would give me a way to test, positively, that the ID method above would work for different stores.

  • What kind of problems are you seeing from using the url_key from the catalog_product.info API calls that are not "always" working? What isn't working across the multiple stores?
    – mttjohnson
    Nov 25, 2013 at 21:10

2 Answers 2


I'm not sure if this is what you need, but here is a simple extension that allows you to get the product url.
The main idea is to rewrite the info method in the product api model and make it return the url of the product also.
For this you will need the following files:
app/etc/modules/[Namespace]_[Module].xml - the declaration file

<?xml version="1.0"?>
                <Mage_Catalog />
                <Mage_Api />

app/code/local/[Namespace]/[Module]/etc/config.xml - the configuration file

<?xml version="1.0"?>

app/code/local/[Namespace]/[Module]/Model/Product/Api.php - your new class

class [Namespace]_[Module]_Model_Product_Api extends Mage_Catalog_Model_Product_Api {
    public function info($productId, $store = null, $attributes = null, $identifierType = null){
        $product = $this->_getProduct($productId, $store, $identifierType);
        $result = parent::info($productId, $store = null, $attributes = null, $identifierType = null);
        //add a new element in here called product_url. You can even wrap it in some condition to see if the product is assigned to the current website or if the product is enabled or visible. ($product->getWebsiteIds(), $product->getStatus(), $product->getVisibility()). 
        $result['product_url'] = $product->getUrlInStore($store);
        return $result;

Note: This works only for API V1. In order to make it work for v2 you need to add a wsdl to your module. See how you can do it.


I think url_path is a more accurate choice than url_key. I'm not certain but I think url_path ends up being a unique value, where two products could share the same url_key. You can get url_path from the catalog_product.info API call and you should be able to specify the optional storeView argument for the API call to make the response specific to an individual store. You can use the store.list API call to get a complete list of all stores in your Magento installation. It wouldn't be very efficient making multiple calls for each store, but it would give you the relevant information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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