views:

39

answers:

2

I am writing a Magento extension and I just cannot get it to show up in the core resources table. I believe I am declaring the resources part of my config correctly. Can someone help me wrap my head around this? Thanks in advance!

<?xml version="1.0"?>
<config>
    <modules>
        <CTRL_Analytics>
            <version>0.2.0</version>
        </CTRL_Analytics>
    </modules>
    <global>
      <blocks>
        <analytics>
          <class>CTRL_Analytics_Block</class>
        </analytics>
      </blocks>

       <helpers>
          <analytics>
            <class>CTRL_Analytics_Helper</class>
          </analytics>
      </helpers>

      <resources>
        <analytics_setup>
            <setup>     
                <module>CTRL_Analytics</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </analytics_setup>

        <analytics_write>
            <connection>
                <use>core_write</use>
            </connection>
        </analytics_write>

        <analytics_read>
            <connection>
                <use>core_read</use>
            </connection>
        </analytics_read>
      </resources>

    </global>
    <adminhtml>
        <menu>
          <analytics translate="title" module="analytics">
              <title>Marketing and Analytics</title>
              <sort_order>100</sort_order>
              <action>analytics/admin</action>
          </analytics>
        </menu>
    </adminhtml>
    <frontend>
        <routers>
            <CTRL_Analytics>
                <use>standard</use>
                <args>
                    <module>CTRL_Analytics</module>
                    <frontName>analytics</frontName>
                </args>
            </CTRL_Analytics>
        </routers>
    </frontend>
</config>
A: 

Firstly (and I'm sure you've done this), clear and disable all cache.

Secondly, check that you able to access the Blocks and Helpers. If not, it might be a problem with your app\etc\modules\CTRL_Analytics.xml. Does the module show up in the Admin under System>Config>Advanced?

Thirdly, do you have your sql\analytics_setup\mysql4-install-0.1.0.php and sql\analytics_setup\mysql4-upgrade-0.1.0-0.2.0.php correctly named and coded. I've found the mysql upgrade naming convention has tripped up a lot of people in the past.

Finally, try putting your server into debug and setting a breakpoint inside the mysql4-install-0.1.0.php to check whether the file is actually getting executed. It might be attempting to run but silently failing on an SQL error (hate that!).

Hope one of these helps! JD

Jonathan Day
I tried all of the above. I realize now that mysql4-install-0.1.0.php is not being executed.
300Stack
Something like echo "here"; exit(); should work as a break point correct?
300Stack
Shouldn't "analytics_setup" be written to the core_resources table when magento instantiates or does it depend on the successful execution of mysql4-install-0.1.0.php before it writes to core_resources?
300Stack
does "echo 'hello'; exit()'" work as a breakpoint? Effectively, yes, but in its most useful form, no. Have a read of my answer here (http://stackoverflow.com/questions/3329248/) to help setup your development environment so that you can debug using a toolset. That will allow you to trace through the stack, examine the value of variables and generally get a HUGE improvement in your understanding of how Magento's codebase actually works. You won't believe that you used to use "echo 'blah'; die();" once you get it working :) Good luck!
Jonathan Day
I'm not certain on when `core_resources` gets written, whether its before or after executing the install MySQL. Based on what you're seeing, I'd guess that it's after!
Jonathan Day
+1  A: 

Looking at your XML, you're naming your installer file

"mysql4-install-0.1.0.php", 

but your starting module version is

"<version>0.2.0</version>"  

Try changing your starting version to

"<version>0.1.0</version>"

or changing your installer file to

"mysql4-install-0.2.0.php".  

Those file version numbers come from your module version number.

I always drop an exit or exception into any new installer file to make sure PHP is trying to load the file. Information is written out to the core_resource table only after a successful execution of this file, an exit or exception will prevent that writing. This allows you to reload the page and have an installer run again and again until you get it right.

Alan Storm
Nice catch Alan, I didn't read it carefully enough. @user, I guess Alan answered your question about the sequence of writing to `core_resource`!
Jonathan Day
Thank you Alan and Jonathan! Both sets of advice contributed to the success of this script.
300Stack