如何从 Magento 中的 SKU 获取产品的 Url [英] How can I get the Url of a product from its SKU in Magento

查看:24
本文介绍了如何从 Magento 中的 SKU 获取产品的 Url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题很简单.如果我知道我的产品的 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 获取产品的 Url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆