2017-07-17 139 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的邏輯並找出類沒有包含安裝程序文件的原因。