向 Magento 核心模块添加额外控制器的最佳实践是什么
我想将名为 SkuController 的附加控制器添加到 CatalogSearch Core 模块。 执行此操作的最佳实践是什么?
谢谢。
I want to add additional controller named SkuController to CatalogSearch Core module.
What is best practice to do this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所有额外的功能都应该由模块来实现。我建议用新控制器制作一个新模块。
all extra funcionality should made by module. I recomend made a new module with the new controller.
无论您做什么,都不要修改核心,而是创建自定义模块,并确保始终尽可能调用父函数。
使用 ModuleCreater 来简化此任务:
http://www.magentocommerce.com/magento-connect/modulecreator.html
看看 Ivan 的视频教程,忽略 php 单元测试部分,但他解释了全部内容,尤其是在视频中的一半。
http://vimeo.com/35937480
另请参阅此示例以获取更多想法:
http://www.magentocommerce .com/knowledge-base/entry/magento-for-dev-part-3-magento-controller-dispatch
在两个链接上共享的良好最佳实践想法。
控制器类可能如下所示:
Whatever you do, do not modify the core, but create a custom module, and ensure you always call the parent functions where possible.
Use ModuleCreater to simplify this task:
http://www.magentocommerce.com/magento-connect/modulecreator.html
Have a look at Ivan's video tutorial, just ignore the php unit testing bit, but he explains the whole lot, especially half way during the video.
http://vimeo.com/35937480
Also look at this sample for some more ideas:
http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-3-magento-controller-dispatch
Good best practice ideas shared on both links.
A controller class could look like this: