The question is simple. If I know the sku of my product and nothing else, how can I retrieve the url to that item. This is commonly useful for third party integration where the unique id at the remote service wont match a product id. Or maybe you want to make a search box to search by sku only.
Check the URL of the loaded page. You will see a URL with the following format: https://{account-name}.vtexcommercestable.com.br/admin/Site/SkuForm.aspx?IdSku={number} The SKU Id will be the number displayed in the place of {number}
You can be assigned Product URL to any page in store for a redirect to Product page. If you want to get Only Url Key value, You can access by $product->getUrlKey() method. You can product full URL by getProductUrl() method.
You can just do this:
$sku = 'ecco'; // SKU you want to load. 'ecco' is a sku in the Magento demo data
$url = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku)->getProductUrl();
echo $url;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With