我的模块安装程序没有运行,也没有进入资源表 [英] My Module installer doesnt run and doesnt gets into the resource table

查看:64
本文介绍了我的模块安装程序没有运行,也没有进入资源表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究一个模块,该模块需要将一些属性添加到sales_orders表中.所以我想我将制作一个资源安装脚本并将其添加到XML.对我来说,这不是一件容易的事.老实说,我不能使它工作.我已经搜索了几个小时才能找到解决方案,但是我还没有找到它.奇怪的是我的模块不在core_resource表中...

I've been working on a module that needs some attributes added to the table of sales_orders. So i thought i will make an resource install script and add it to the XML. Well for me this wasn't a easy task. To be really honest I cant make it work. I have searched some hours to get the solution, but i haven't found it. The weird thing is that my module isnt at the core_resource table...

这是我的XML.我对XML编辑有点陌生.也许我犯了一个错误.

Well this is my XML. I'm a bit new to XML editing. Maybe i have made an error.

XML:

<config>
        <global>
       <modules>
        <Sendcloud_Magento>
            <version>0.2.0</version>
        </Sendcloud_Magento>
    </modules>
    <helpers>
          <magento>
            <class>Sendcloud_Magento_Helper</class>
        </magento>
        </helpers>
      <models>
        <magento>
               <class>Sendcloud_Magento_Model</class>
            <resourceModel>magento_resource</resourceModel>
        </magento>
          <magento_mysql4>
            <class>Sendcloud_Magento_Model_Mysql4</class>
        </magento_mysql4>
     </models>

    <resources>
<!-- ... -->
<magento_setup>
    <setup>
        <module>Sendcloud_Magento</module>
        <class>Sendcloud_Magento_Model_Resource_Mysql4_Setup</class>
    </setup>
    <connection>
        <use>core_setup</use>
    </connection>
</magento_setup>
<!-- ... -->
</resources>
</global>
 <admin>
    <routers>
        <magento>
            <use>admin</use>
            <args>
                <module>Sendcloud_Magento</module>
                <frontName>sendcloud</frontName>
            </args>
        </magento>
    </routers>
</admin>
<adminhtml>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <sendcloud>
                                        <title>Sendcloud</title>
                                    </sendcloud>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>

    <layout>
        <updates>
            <magento>
                <file>magento.xml</file>
            </magento>
        </updates>
    </layout>
    <events>
        <core_block_abstract_prepare_layout_before>
            <observers>
                <magento_core_block_abstract_prepare_layout_before>
                    <class>Sendcloud_Magento_Model_Observer</class>
                    <method>addMassAction</method>
                </magento_core_block_abstract_prepare_layout_before>
            </observers>
        </core_block_abstract_prepare_layout_before>
    </events>
</adminhtml>

我已经在模块中放置了一个安装脚本.路径 /local/Sendcloud/Magento/sql/magento_setup/mysql4-install-0.2.0.php

Ive put an installer script in my module. the path /local/Sendcloud/Magento/sql/magento_setup/mysql4-install-0.2.0.php

echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
die("Exit for now");    

我有一个模型 Sendcloud/Magento/Model/Resource/Mysql4/Setup.php

I have an model made in Sendcloud/Magento/Model/Resource/Mysql4/Setup.php

class Sendcloud_Magento_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
}

我希望你们中的一些人能解决我的问题.

I hope some of you have an solution to my question.

最诚挚的问候和新年快乐,

Best regards and a happy new year,

保罗

推荐答案

因此,现在您需要将版本从0.2.0更新到0.3.0,请尝试

So now you need to update the version from 0.2.0 to 0.3.0, Try this

应用程序\代码\本地\ Sendcloud \ Magento \ etc \ config.xml

<?xml version="3.0"?>
<config>
    <modules>
        <Sendcloud_Magento>
            <version>0.3.0</version>
        </Sendcloud_Magento>
    </modules>
    <frontend>
        <routers>
            <magento>
                <use>standard</use>
                <args>
                    <module>Sendcloud_Magento</module>
                    <frontName>magento</frontName>
                </args>
            </magento>
        </routers>
    </frontend>
    <global>
        <models>
            <magento>
                <class>Sendcloud_Magento_Model</class>
                <resourceModel>magento_mysql4</resourceModel>
            </magento>
            <magento_mysql4>
                <class>Sendcloud_Magento_Model_Mysql4</class>
                <entities>
                    <magento>
                        <table>magento</table>
                    </magento>
                </entities>
            </magento_mysql4>
        </models>
        <resources>
            <magento_setup>
                <setup>
                    <module>Sendcloud_Magento</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </magento_setup>
            <magento_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </magento_write>
            <magento_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </magento_read>
        </resources>
    </global>
</config>

应用程序\代码\本地\ Sendcloud \ Magento \ Model \ Magento.php

class Sendcloud_Magento_Model_Magento extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        parent::_construct();
        $this->_init('magento/magento');
    }
}

应用程序\代码\本地\ Sendcloud \ Magento \ Model \ Mysql4 \ Magento.php

class Sendcloud_Magento_Model_Mysql4_Magento extends Mage_Core_Model_Mysql4_Abstract
{
    public function _construct()
    {    
        // Note that the magento_id refers to the key field in your database table.
        $this->_init('magento/magento', 'magento_id');
    }
}

应用程序\代码\本地\ Sendcloud \ Magento \ Model \ Mysql4 \ Magento \ Collection.php

class Sendcloud_Magento_Model_Mysql4_Magento_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
    {
        public function _construct()
        {
            parent::_construct();
            $this->_init('magento/magento');
        }
    }

应用程序\代码\本地\ Sendcloud \ Magento \ sql \ magento_setup \ mysql4-upgrade-0.2.0-0.3.0.php

$installer = $this;

$installer->startSetup();

$installer->addAttribute(
));

$installer->endSetup(); 

app \ etc \ modules \ Sendcloud_Magento.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Sendcloud_Magento>
            <active>true</active>
            <codePool>local</codePool>
        </Sendcloud_Magento>
    </modules>
</config> 

这篇关于我的模块安装程序没有运行,也没有进入资源表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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