dtdsbakn210537 2010-12-17 00:09
浏览 28
已采纳

Magento一致的产品网址

Magento seems to have a number of different formats that work for product URLs, including:

/catalog/product/view/id/123/s/my-product-slug/
/my-product-slug/
/top-category/sub-category/my-product-slug/
etc...

I want to just use one of these, always, which is the 3rd one, concatenating all parent category slugs together before the product slug. Is there a way to configure Magento to only use one of these formats?

Using methods like getProductUrl() seems to return different results depending on what page/context you're on, can anyone tell me why this is?

And in general does anyone know of any documentation or blog posts, etc., that might help me understand routing in Magento a little better?

Thanks!

  • 写回答

3条回答 默认 最新

  • doujiao9426 2011-01-06 23:07
    关注

    clockworkgeek was pretty close and led me to my answer...

    I tried using $product->setCategoryId() and was finding that $product->getCategoryId() wasn't returning anything and that the Mage_Catalog_Model_Product_Url::getUrl method depends on the getCategoryId method on the product model to figure out a product's URL. Turns out getCategoryId is explicitly defined in the product model (not a magic method like I assumed) that returns the value of Mage::registry('current_category'). So basically I registered and unregistered 'current_category' to meet my needs.

    This still leaves my question partially unanswered though. I figured out how to hack around and get what URL I wanted, but technically the messy /catalog/product/view/id/123/s/my-product-slug/-type URLs still work and I'd rather all of the URL varieties route to the category-fied one. It would be great to be able to define a single, canonical URL style in Magento. If anyone has any further insight on this please let me know!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题