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.
Best Answer
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 fileapp/code/local/[Namespace]/[Module]/etc/config.xml
- the configuration fileapp/code/local/[Namespace]/[Module]/Model/Product/Api.php
- your new classNote: 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.