使用SQL查询可以获得“友好”的URL吗?

时间:2014-04-28 21:00:59

标签: mysql sql magento

我有一个网站(不是我的magento网站),我连接到magento的数据库并使用一些SQL查询来显示最近的产品。我知道我应该使用API​​,但现在不是这样。

我只是将"http://www.domain.com/catalog/product/view/id/"附加到产品ID。

它运作正常,我只是想知道是否可以为我在商店中获得的每件商品获得相同的友好网址,例如http://www.domain.com/dvd/movies/matrix-3.html

我该怎么做?

1 个答案:

答案 0 :(得分:2)

Marcelo,magento在目录产品表和core_rewrite_url中保存了产品seo url

这里是查询

Select product_id, request_path from  core_url_rewrite 
where store_id=$storeId and product_id =$ProductID and is_system=1  

这里core_url_rewrite表提供了产品的所有网址。 给出

http://www.domain.com/dvd/movies/matrix-3.html
http://www.domain.com/dvd/matrix-3.html

如果产品包含在某个类别中,则在查询

下运行
    Select product_id, request_path from  core_url_rewrite 
    where store_id=$storeId and product_id =$ProductID  and is_system=1  
   and category_id=$categoryId

查询提供http://www.domain.com/dvd/movies/matrix-3.html

相关问题