您常见的 Magento 配置错误有哪些?

发布于 2024-08-25 19:02:28 字数 229 浏览 12 评论 0原文

如果说每个人都讨厌 Magento 的话,那就是在能够编写一些代码之前无休止地配置模块。我正在尝试为我即将启动的未来项目收集常见的 Magento 配置错误列表。

我正在寻找具体的示例,例如在类名上使用错误的命名约定,在设置分组类名时忘记 包装器。诸如此类的小事会让你抓狂几个小时,直到你意识到自己的错误。

越详细越好!

If there's something that everybody hates about Magento it's endlessly configuring your modules before being able to write some code. I'm trying to collect a list of common Magento configuration errors for a future project that's I'm close to launching.

I'm looking for specific examples of things like using the wrong naming convention on classnames, forgetting the <class /> wrapper when setting up grouped class names. Little things like that that drive you batty for hours until you realize your error.

The more details the better!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清风无影 2024-09-01 19:02:28

在 /app/etc/module/your_Module.xml 中camelcase codePool 否则会失败

<?xml version="1.0"?>
<config>
    <modules>
        <Your_Module>
            <!-- <codepool>local</codepool> this will fail silently-->
            <codePool>local</codePool>
            <active>true</active>
        </Omx_Hooks>
    </modules>
</config>

in /app/etc/module/your_Module.xml camelcase codePool otherwise will fail

<?xml version="1.0"?>
<config>
    <modules>
        <Your_Module>
            <!-- <codepool>local</codepool> this will fail silently-->
            <codePool>local</codePool>
            <active>true</active>
        </Omx_Hooks>
    </modules>
</config>
っ左 2024-09-01 19:02:28

使用 moduleCreator 有助于避免大量配置错误,但一个大问题(与 Elzo 的答案相比具有讽刺意味)是在模块名称中使用驼峰命名法。在 Windows 系统上开发时它会完美地工作,但在 *nix 上会默默地失败。

Module_UsingCamelCaseFails

虽然

Module_Uselowercasetosucceed

我还没有尝试在 *nix 上创建驼峰式模块,因为我确实看到具有该命名约定的模块可以工作,但在 Windows->Linux 方向肯定会引起麻烦。

在 adminhtml 中创建顶级菜单时,我也很难坚持 ACL。如果您的菜单条目是 的子项,则 ACL 可以正常工作,但不能作为一级节点。

当我第一次开始 Magento 开发时花了一段时间的另一个经典是忘记了你不能通过将控制器放在 app/code/local/Mage 中来覆盖它。

我希望看到一种与 ConfigViewer 实际上相反的工具,即验证您的 config.xml 的工具在您指定的事件、对象和其他值的上下文中,并且应该存在于安装的其余部分中。基本的 XSL 解析将是第一遍,然后尝试实例化任何引用的对象。不确定如何验证观察到的事件,但也许 grep 该事件名称的核心代码可以工作。想法?

Using the moduleCreator helps to avoid a lot of configuration mistakes, but one big gotcha (ironically compared to Elzo's answer) is using camelCase in a module name. It will work perfectly when developing on a Windows system, but fails silently on *nix.

Module_UsingCamelCaseFails

whereas

Module_Uselowercasetosucceed

I haven't tried creating a camel case module on *nix as I do see modules with that naming convention that work, but certainly in Windows->Linux direction will cause trouble.

I've also had difficulty getting ACLs to stick when creating a top level menu in the adminhtml. If your menu entry is a child of <cms> or <catalog>, the ACLs work fine, but not as a first class node.

The other classic that took a while when I first started Magento development, was forgetting that you can't override a controller by just placing it in app/code/local/Mage.

I'd love to see a tool that is effectively the inverse of ConfigViewer, ie one that validates your config.xml in the context of the events, objects and other values you've specified and should exist in the rest of the install. A basic XSL parse would be the first pass, then attempt to instantiate any referenced objects. Not sure how you would validate observed events, but perhaps grepping the core code for that event name could work. Thoughts?

只等公子 2024-09-01 19:02:28

重写块、模型或助手时,请确保路径指向现有块并且路径中没有拼写错误。

例如,我只是花了很多时间弄清楚为什么以下重写不起作用:

<blocks>  
  <adminhtml>  
     <rewrite>    <sales_order_views_tabs>Path_to_My_class</sales_order_views_tabs>  
     </rewrite>  
  </adminhtml>  
</blocks>  

如您所见,我在需要“视图”的地方有“视图”。因此,不存在我试图重写的块,因此没有错误,也没有重写。

艾伦,一旦我开始 Configlint 工作,我想自己写这个案例。我安装时遇到问题。我已在“gitHub”上发布了该问题。我想自己做,因为我想参与这个项目,

谢谢,
玛戈茨

When rewriting blocks, models or helpers make sure that the path is pointing to existing block and there is no misspell in the path.

For example, I just spent a lot time figuring out why the following rewrite didn't work:

<blocks>  
  <adminhtml>  
     <rewrite>    <sales_order_views_tabs>Path_to_My_class</sales_order_views_tabs>  
     </rewrite>  
  </adminhtml>  
</blocks>  

As you can see it i have 'views' where it needs to be 'view'. Thus, there does not exist the block i am trying to rewrite resulting no errors and no rewrites as well.

Alan, I would like to write the case myself once i will get the Configlint work. I am having issue installing it. The issue I have posted at the 'gitHub'. I want to do myself because i want to be involved in this project

thanks,
Margots

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文