2017-07-17 287 views
0

我是Magento的初学者,我从开发小型扩展开始。Magento 1.9安装脚本不运行

我已经安装了它,一切都很好。但由于某种原因,我决定重新安装它。我从core_resource表中删除了行,我也从DB中删除了模块表。在.xml配置文件中我已经把虚假

现在扩展不工作(当然)。但它仍然显示在配置 - >高级 - >模块输出!我不知道为什么。我甚至只是删除从目录中的所有文件和文件夹,我清除缓存Magento的(这实际上是在我的系统设置为“已禁用”)

以下是config.xml文件:

<?xml version="0.0.1" encoding="UTF-8" ?> 
<config> 
    <modules> 
     <Anglingdirect_Jobadverts> 
      <version>0.0.1</version> 
     </Anglingdirect_Jobadverts> 
    </modules> 
    <global> 
     <helpers> 
      <jobadverts> 
       <class>Anglingdirect_Jobadverts_Helper</class> 
      </jobadverts> 
     </helpers> 
     <blocks> 
      <jobadverts> 
       <class>Anglingdirect_Jobadverts_Block</class> 
      </jobadverts> 
     </blocks> 
     <models> 
      <jobadverts> 
       <class>Anglingdirect_Jobadverts_Model</class> 
       <resourceModel>jobadverts_mysql4</resourceModel> 
      </jobadverts> 
      <jobadverts_mysql4> 
       <class>Anglingdirect_Jobadverts_Model_Mysql4</class> 
       <entities> 
        <advert> 
         <table>job_adverts</table> 
        </advert> 
        <category> 
         <table>job_categories</table>job 
        </category> 
        <application> 
         <table>job_applications</table> 
        </application> 
        <location> 
         <table>aw_storelocator_location</table> 
        </location> 
       </entities> 
      </jobadverts_mysql4> 
     </models> 
     <resources> 
      <jobadverts_setup> 
       <setup> 
        <module>Anglingdirect_Jobadverts</module> 
        <class>Anglingdirect_Jobadverts_Model_Mysql4_Setup</class> 
       </setup> 
       <connection> 
        <use>core_setup</use> 
       </connection> 
      </jobadverts_setup> 
      <jobadverts_read> 
       <connection> 
        <use>core_read</use> 
       </connection> 
      </jobadverts_read> 
      <jobadverts_write> 
       <connection> 
        <use>core_write</use> 
       </connection> 
      </jobadverts_write> 
     </resources> 

    </global> 
    <frontend> 
     <routers> 
      <jobadverts> 
       <use>standard</use> 
       <args> 
        <module>Anglingdirect_Jobadverts</module> 
        <frontName>career</frontName> 
       </args> 
      </jobadverts> 
     </routers> 
     <layout> 
      <updates> 
       <jobadverts> 
        <file>jobadverts.xml</file> 
       </jobadverts> 

      </updates> 
     </layout> 
    </frontend> 
    <admin> 
     <routers> 
      <jobadverts> 
       <use>admin</use> 
       <args> 
        <module>Anglingdirect_Jobadverts</module> 
        <frontName>adminhtml_jobadverts</frontName> 
       </args> 
      </jobadverts> 
     </routers> 
    </admin> 
    <!--<admin>--> 
     <!--<routers>--> 
      <!--<Anglingdirect_Jobadverts>--> 
       <!--<use>admin</use>--> 
       <!--<args>--> 
        <!--<module>Anglingdirect_Jobadverts</module>--> 
        <!--<frontName>admin_jobadverts</frontName>--> 
       <!--</args>--> 
      <!--</Anglingdirect_Jobadverts>--> 
     <!--</routers>--> 
    <!--</admin>--> 
    <adminhtml> 
     <menu> 
      <adextensions module="anglingdirect_jobadverts"> 
       <title>AD Extensions</title> 
       <sort_order>100</sort_order> 
       <children> 
        <jobadverts module="jobadverts"> 
         <title>Job adverts</title> 
         <sort_order>150</sort_order> 
         <children> 
          <application module="jobadverts"> 
           <title>Post a job</title> 
           <sort_order>0</sort_order> 
           <action>adminhtml_jobadverts/adminhtml_advert/new</action> 
          </application> 

          <advert module="jobadverts"> 
           <title>Job management</title> 
           <sort_order>10</sort_order> 
           <action>adminhtml_jobadverts/adminhtml_advert/index</action> 
          </advert> 

          <browse module="jobadverts"> 
           <title>Job applications</title> 
           <sort_order>20</sort_order> 
           <action>adminhtml_jobadverts/adminhtml_application</action> 
          </browse> 
         </children> 
        </jobadverts> 
       </children> 
      </adextensions> 
     </menu> 

     <layout> 
      <updates> 
       <jobadverts module="jobadverts"> 
        <file>jobadverts.xml</file> 
       </jobadverts> 
      </updates> 
     </layout> 
    </adminhtml> 

</config> 

这里是我的安装mysql4安装-0.1.0.php脚本:

<?php 
/* @var $installer Mage_Catalog_Model_Resource_Setup */ 
$installer->startSetup(); 
// anglingdirect_jobadverts/job_adverts 
$table_adv = $installer->getConnection() 
    ->newTable($installer->getTable('job_adverts')) 
    ->addColumn('job_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
     'identity' => true, 
     'unsigned' => true, 
     'nullable' => false, 
     'primary' => true, 
    ),'job post id') 
    ->addColumn('job_cat_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
     'nullable' => false, 
    ),'Job category ID') 
    ->addColumn('job_title', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'Job Title') 
    ->addColumn('job_hours', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'Working time') 
    ->addColumn('job_salary', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'Salary') 
    ->addColumn('job_location', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
     'nullable' => false, 
    ),'Location') 
    ->addColumn('job_active', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
     'nullable' => false, 
    ), 'Advert status: removed, active') 
    ->addColumn('job_descr', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ), 'Full job description') 
    ->setComment('Job adverts table'); 

$table_app = $installer->getConnection()->newTable($installer->getTable('job_applications')) 
    ->addColumn('job_app_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
     'identity' => true, 
     'unsigned' => true, 
     'nullable' => false, 
     'primary' => true, 
    ),'job post id') 
    ->addColumn('job_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
     'nullable' => false, 
    ),'Application ID') 
    ->addColumn('applicant_name', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'Applicant full name') 
    ->addColumn('applicant_email', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'Contact email') 
    ->addColumn('applicant_letter', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'Motivation letter') 
    ->addColumn('applicant_cv', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'path to file with cv') 
    ->addColumn('applicant_status', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
     'nullable' => false, 
    ), 'Applicant succeed, application declined, removed') 
    ->setComment('Job applications table'); 


$table_cat = $installer->getConnection()->newTable($installer->getTable('job_categories')) 
    ->addColumn('job_cat_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
     'identity' => true, 
     'unsigned' => true, 
     'nullable' => false, 
     'primary' => true, 
    ),'Category ID') 
    ->addColumn('job_cat_path', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'Category title') 
    ->addColumn('job_cat_title', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'Category title') 
    ->addColumn('job_cat_image', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
     'nullable' => false, 
    ),'Category image') 

    ->addIndex($installer->getIdxName('job_categories', array('job_cat_id')),array('job_cat_id')) 
    ->setComment('Job categories table'); 

$installer->getConnection()->createTable($table_adv); 
$installer->getConnection()->createTable($table_app); 
$installer->getConnection()->createTable($table_cat); 

$installer->endSetup(); 

这里是文件夹结构: Screenshot of my extension folder structure

我怎样才能重新安装我的EXTENS离子在这种情况下?请帮助

回答

0

已解决。问题是,因为我没有与类文件:

Anglingdirect_Jobadverts_Model_Mysql4_Setup

现在它的罚款。我从项目文件夹中删除了这个扩展文件并将它们返回。安装脚本然后运行。

干杯

+0

你不需要这个类,你可以使用核心设置类 - 它只是重要的是什么资源类,你在你的config.xml中定义了:) –

0

通过this article工作,以确保您对设置资源的功能,工作方式以及排除故障方式没有任何误解。

一旦你这样做了,从你在这个问题上所说的一切,听起来就像是让你的资源“安装”了,但是你的安装脚本永远不会运行。我的猜测是,你在

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

使用的版本号并未在模块

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

那些应该匹配的脚本运行的版本匹配。我认为 Magento足够聪明,可以运行以前的版本,如果它发现它们,但在设置资源中的代码是难以遵循的那种,所以我总是确保它们匹配。

无论如何,你可以看到magento在运行你的设置资源时试图运行哪个文件。删除与您的模块相关的core_resource中的任何条目。清除缓存。然后发现在设置类

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; 
    } 

,然后对其进行修改以下位置增加一些临时调试例外

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缓存哪些模块需要检查安装/升级)

如果这样做不起作用,请开始探究applyAllDataUpdates的逻辑并找出类没有包含安装程序文件的原因。