我的Magento的扩展安装脚本将不会运行 [英] My Magento Extension Install Script Will Not Run

查看:133
本文介绍了我的Magento的扩展安装脚本将不会运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的扩展,由于某种原因,它不会安装脚本创建安装脚本。扩展将在core_resource表上显示,但属性我想创建不会产生。

I am trying to create an install script for my extension and for some reason it will not the install script. The extension will show up in the core_resource table, but the attributes I am trying to create will not create.

我是pretty确保该脚本甚至没有被调用,因为我把一个出口()在开始和现场跑了就好了。

I am pretty sure that the script is not even being called because I put an exit() at the beginning and the site ran just fine.

下面是我在我的配置XML文件。这是摆全球内 - >资源路径:

Here is what I have in my config XML file. This is placed inside global -> resources path:

<nie_setup>
    <setup>
        <module>Nie_Nie</module>
    </setup>
    <connection>
        <use>core_setup</use>
    </connection>
</nie_setup>

我的安装脚本如下:

My install script is as follows:

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();

$setup->addAttribute('customer', 'nie_admin', array(
    'input'                 => 'text',
    'type'                  => 'text',
    'backend'               => '',
    'visible'               => 0,
    'required'          => 0,
    'user_defined'  => 1,
));

$installer->endSetup();

有什么明显的,我在这里失踪,这将是该脚本将不会运行的原因是什么?

Is there something obvious I am missing here that would be the reason the script will not run?

推荐答案

工作通过自己的方式这篇文章,以确保你不具有的设置资源做任何误解,他们是如何工作的,以及如何解决它们。

Work your way through this article to make sure you don't have any misunderstanding of what the setup resources do, how they work, and how you can troubleshoot them.

一旦你做到了这一点,从一切你已经在这个问题上说线程这听起来像你得到你的资源已安装,但你的安装脚本从不运行。我的猜测是,你所使用的版本号

Once you've done that, from everything you've said on this question thread it sounds like you're getting your resource "installed", but that your install script never runs. My guess is that the version number you used in

//0.0.1 is your version number
mysql4-install-0.0.1.php

没你的模块的版本匹配

didn't match up with the version of your module

<modules>
    <Nie_Nie>
        <version>?.?.?</version>
    </Nie_Nie>
</modules>

那些应该匹配的脚本运行。 我觉得的Magento是足够聪明,运行previous版本,如果发现他们,但在设置资源$ C ​​$ C是很难遵循的那种,所以我总是确保他们匹配

Those should match for the script to run. I think Magento is smart enough to run previous versions if it finds them, but the code in the setup resources is the kind that's hard to follow, so I always make sure they match.

不管怎样,这里是你如何能看到哪些文件(S)的Magento试图当它运行您的设置的资源来运行。 DELETE FROM core_resource 与您的模块的任何条目。清除缓存。然后找到在设置类以下位置

Regardless, here's how you can see which file(s) magento is trying to run when it runs your setup resource. Delete any entries from core_resource related to your module. Clear your cache. Then find the following locations in the setup class

File: app/code/core/Mage/Core/Model/Resource/Setup.php

protected function _modifyResourceDb($actionType, $fromVersion, $toVersion)
{
    ... 

    $sqlFilesDir = Mage::getModuleDir('sql', $modName).DS.$this->_resourceName;        

    if (!is_dir($sqlFilesDir) || !is_readable($sqlFilesDir)) {
        return false;
    }

    ...

    $sqlDir->close();

    if (empty($arrAvailableFiles)) {
        return false;
    }

    ...

    $arrModifyFiles = $this->_getModifySqlFiles($actionType, $fromVersion, $toVersion, $arrAvailableFiles);
    if (empty($arrModifyFiles)) {
        return false;
    }

再修改它们添加一些临时调试例外

and then modify them to add some temporary debugging exceptions

    if (!is_dir($sqlFilesDir) || !is_readable($sqlFilesDir)) {
        throw new Exception("$sqlFilesDir not found");
        return false;
    }

    ...

    if (empty($arrAvailableFiles)) {
        throw new Exception("No files found to run");
        return false;
    }

    ...

    $arrModifyFiles = $this->_getModifySqlFiles($actionType, $fromVersion, $toVersion, $arrAvailableFiles);
    if (empty($arrModifyFiles)) {
        throw new Exception("No valid upgrade files found to run for ");
        return false;
    }

    throw new Exception("If you're getting here, we have a file.  Remove your exceptions here and place one in your installer to make sure it's the one you think it is.");

重新加载页面,你会得到异常文本抱怨什么的Magento找不到。这应该是足以帮助你跟踪哪些安装脚本的Magento试图运行,但没有找到。不过,别忘了删除模块的行 core_resource 和清除缓存。 (Magento的缓存哪些模块需要检查的安装/升级)

Reload the page and you'll get exception text complaining about whatever Magento can't find. That should be enough to help you track down which installer script Magento is trying to run, but failing to find. Just remember to delete your module's row in core_resource and to clear your cache. (Magento caches which modules need to check for an install/upgrade)

如果不工作,开始挖成 applyAllDataUpdates 的逻辑并找出为何类不包括您的安装程序文件。

If that doesn't work, start digging into the logic of applyAllDataUpdates and figure out why the class isn't including your installer file.

这篇关于我的Magento的扩展安装脚本将不会运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆