skip to Main Content

I am a beginner with Magento and I started from developing small extension.

I had it already installed and everything was fine. But by some reason I decided to reinstall it. I removed rows from core_resource table, I removed module tables from DB as well. In .xml config file I’ve put false

Now extension is not working (of course). But it still show up in Configuration -> Advanced – > Module output! And I have no idea why. I even just removed all files and folders from the directory, I cleared Magento cache (which actually is set as “disabled” in my system)

Here is 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> 

Here is my install mysql4-install-0.1.0.php script:

<?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();

Here is folder structure:
Screenshot of my extension folder structure

How can I re-install my extension in this situation? Please help

2

Answers


  1. Chosen as BEST ANSWER

    Solved. The problem was because I didn't have file with class:

    Anglingdirect_Jobadverts_Model_Mysql4_Setup

    Now it's fine. I removed this extension files from project folder and returned them back. Install script then has run.

    Cheers


  2. 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>
    

    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.

    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.");
    

    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)

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search