如何从Magento的SKU获取产品的网址 [英] How can I get the Url of a product from its SKU in Magento
本文介绍了如何从Magento的SKU获取产品的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题很简单. 如果我只知道产品的SKU,而又不知道其他什么,我该如何检索该产品的URL.这对于第三方集成通常很有用,在第三方集成中,远程服务上的唯一ID与产品ID不匹配.或者,也许您想创建一个仅按sku进行搜索的搜索框.
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.
推荐答案
您可以执行以下操作:
$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;
这篇关于如何从Magento的SKU获取产品的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文