0

Problem

I'm creating a simple module that contains two tables named:

  • city_faq
  • city_faq_section

I'm having a difficult time joining city_faq with city_faq_section. Each time I try to do so, I receive the following error:

Can't retrieve entity config: city_faq/city_faq_section.

Additional Information

UPDATE:

After a few hours of debugging, it appears that the problem may stem from the model calling the collection, City_Faq_Model_Faq. In its constructor, I have $this->_init('city_faq/faq');, but this may not be correct. Would this cause the above error?

Here is my join call:

/** $this refers to City_Faq_Model_Resource_Faq_Collection **/
    $this->join(
        array('sections' => $this->getTable('section')),
        'main_table.section_id = sections.section_id',
        array('sections.*')
    )
    ->setOrder('sections.sort', self::SORT_ORDER_ASC)
    ->setOrder('main_table.sort', self::SORT_ORDER_ASC);

Clearly, I'm choking on $this->getTable('section') - however, if add the following right above the join call, I see the correct table in the log file (city_faq_section), so it appears that the config is read correctly.

    Mage::log($this->getTable('section'))

The pertinent section of my config.xml looks like this:

<config>
    <modules>
        <City_Faq>
            <version>0.2.0</version>
        </City_Faq>
    </modules>
    <global>
        <helpers>
            <city_faq>
                <class>City_Faq_Helper</class>
            </city_faq>
        </helpers>
        <models>
            <city_faq>
                <class>City_Faq_Model</class>
                <resourceModel>city_faq_resource</resourceModel>
            </city_faq>
            <city_faq_resource>
                <class>City_Faq_Model_Resource</class>
                <entities>
                    <faq>
                        <table>city_faq</table>
                    </faq>
                    <section>
                        <table>city_faq_section</table>
                    </section>
                </entities>
            </city_faq_resource>
        </models>
        <blocks>
            <city_faq>
                <class>City_Faq_Block</class>
            </city_faq>
        </blocks>
        <resources>
            <city_faq_setup>
                <setup>
                    <module>City_Faq</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </city_faq_setup>
        </resources>
    </global>
</config>

Both tables (city_faq and city_faq_section) exist. I'm sure I'm missing something silly. What's interesting, is when completing the join call, the class City_Faq_Model_Resource_Faq is instantiated but City_Faq_Model_Resource_Section is not. This leads me to believe that this is the issue.

Things I've tried

  • I've tried $this->getTable('city_faq/section')
  • I've even tried setting directly via $this->getTable('city_faq_section')

File Structure

-City
    -Faq
        -Model
            -Resource
                - Faq
                    . Collection.php
                . Faq.php
                . Section.php
            . Faq.php
            . Section.php

        -sql
            -ciy_faq_setup
                . mysql4-install-0.2.0.php
        -etc
            . config.xml
  • 1
    Try with $this->getTable('city_faq/section') instead of $this->getTable('section') – Marius Dec 16 '14 at 15:43
  • Thanks @Marius - Tried that too (should have mentioned that), but the error is still the same and Mage::log($this->getTable('city_faq/section')); still outputs the correct table city_faq_section. I'll update my question with things I've tried. – Phil Birnie Dec 16 '14 at 15:45
  • Strange. Are you sure the problem does not come from an other piece of code? Just asking to make sure. – Marius Dec 16 '14 at 15:47
  • I guess it must be - The installer script uses $installer->getTable('city_faq/section') and the table is installed correctly as well. I'll keep digging. – Phil Birnie Dec 16 '14 at 16:01
1

This turned out to be a fairly silly mistake. Since my module will be similar in structure to the Mage_Poll plugin, I used that as a reference.

Rather than:

$this->join(
        array('sections' => $this->getTable('section')),
        ...

It should have been:

$this->getSelect()->join(
        array('sections' => $this->getTable('section')),
        ...

Now it makes sense why basically everything in the module was working, except for the join statement. Aye...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.