linux - Magento 模块适用于 OS X 而不是 Linux

标签 linux macos magento case-sensitive

我在让我的 magento 模块在 Linux 上运行时遇到问题。 它在 os x 上没有任何问题。

这是我的模块结构

app
├── code
│   └── local
│       └── Vuuh
│           └── ProductFeed
│               ├── Block
│               │   ├── Adminhtml
│               │   │   └── ProductFeed.php
│               │   └── Index.php
│               ├── controllers
│               │   ├── Adminhtml
│               │   │   └── AdminController.php
│               │   └── ProductController.php
│               ├── etc
│               │   ├── adminhtml.xml
│               │   └── config.xml
│               ├── Helper
│               │   └── Data.php
│               ├── Model
│               │   ├── Resource
│               │   │   ├── ProductFeed
│               │   │   │   └── Collection.php
│               │   │   └── ProductFeed.php
│               │   └── ProductFeed.php
│               │
│               └── sql
│                   └── vuuh_productfeed_setup
│                       └── install-0.0.1.php
├── design
│    └── adminhtml
│        └── default
│            └── default
│                ├── layout
│                │   └── productfeed.xml
│                └── template
│                    └── productfeed
│                        └── productfeed.phtml
└── etc
    └── modules
        └── Vuuh_ProductFeed.xml

这是我的config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>

<!-- Module -->
<modules>
    <Vuuh_ProductFeed>
        <version>0.0.1</version>
    </Vuuh_ProductFeed>
</modules>

<!-- Frontend -->
<frontend>
    <routers>
        <vuuh_productfeed>
            <use>standard</use>
            <args>
                <module>Vuuh_ProductFeed</module>
                <frontName>vuuhproductfeed</frontName>
            </args>
        </vuuh_productfeed>
    </routers>
</frontend>

<!-- Admin-->
<admin>
    <routers>
        <Vuuh_ProductFeed>
            <use>admin</use>
            <args>
                <module>Vuuh_ProductFeed</module>
                <frontName>productfeed</frontName>
            </args>
        </Vuuh_ProductFeed>
    </routers>
</admin>

<!-- Adminhtml -->
<adminhtml>
    <layout>
        <updates>
            <productfeed>
                <file>productfeed.xml</file>
            </productfeed>
        </updates>
    </layout>
</adminhtml>

<!-- Global -->
<global>
    <models>
        <vuuh_productfeed>
            <class>Vuuh_ProductFeed_Model</class>
            <resourceModel>vuuh_productfeed_resource</resourceModel>
        </vuuh_productfeed>

        <vuuh_productfeed_resource>
            <class>Vuuh_ProductFeed_Model_Resource</class>
            <entities>
                <productfeed>
                    <table>vuuh_productfeed_productfeed</table>
                </productfeed>
            </entities>
        </vuuh_productfeed_resource>
    </models>
    <resources>
        <vuuh_productfeed_setup>
            <setup>
                <module>Vuuh_ProductFeed</module>
                <class>Mage_Core_Model_Resource_Setup</class>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </vuuh_productfeed_setup>
    </resources>
    <helpers>
        <productfeed>
            <class>Vuuh_ProductFeed_Helper</class>
        </productfeed>
    </helpers>
    <blocks>
        <productfeed>
            <class>Vuuh_ProductFeed_Block</class>
        </productfeed>
    </blocks>
</global>

我研究了一下,发现问题可能是因为 Linux 上区分大小写。但是我在我的配置中找不到任何错误?

Mage::getModel("vuuh_productfeed/productfeed") 找不到类。

$productfeed = Mage::getModel("vuuh_productfeed/productfeed")->getCollection();

Fatal error: Call to a member function getCollection() on a non-object in /var/www/magento18/app/design/adminhtml/default/default/template/productfeed/productfeed.phtml

我已经盯着那个配置看了好几个小时了。我找不到错误。 该模块加载正常。只有一个类不会加载。

最佳答案

问题是区分大小写。 Windows 上的文件名不区分大小写。在 UNIX 上它们是。
所以当调用 Mage::getModel("vuuh_productfeed/productfeed") Magento 寻找文件

Vuuh/ProductFeed/Model/Productfeed.php 但是你的文件名是 Vuuh/ProductFeed/Model/ProductFeed.php

这里有 2 个选项。
例如,将对 getModel(以及 createBlock 和其他工厂)的所有调用更改为

Mage::getModel("vuuh_productfeed/productFeed")

但是这种方法有点耗时。

第二个选项是将文件从 ProductFeed.php 重命名为 Productfeed.php。您还可以更改这些文件中的类名,但这不是强制性的,因为类名在 PHP 中区分大小写。但只是为了“政治正确”,你应该改变它们。

关于linux - Magento 模块适用于 OS X 而不是 Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23762520/

相关文章:

linux - 根据 diff 输出打印 linux 文件中的特定行

linux - subprocess.Popen 在退出时中断终端

macos - Golang下载和 '$GOPATH not set'

Apache:编辑 .conf 文件产生 "Invalid command ' Header'"

mysql - Magento - 为什么在 ListView 中使用带有直接 SQL 的自定义 block 比在 list.phtml 中使用直接 SQL 慢?

c - epoll - 轮询多个文件描述符(即套接字)

linux - ELF NT_FILE 注释的含义

java - M1苹果硅mac上的Dynamodb本地设置

node.js - 安装 yomen 时疑难解答。谁能帮我解决这个问题..!

mysql - 马根托。 SQL 错误 #1452 - 无法添加或更新子行 : a foreign key constraint fails