Magento module not added to core_resource table - magento

I am trying to write a script which has to execute when a module is updated. I wanted to check the version in db table core_resource, but i see now that the module is not added there. Am i looking in the wrong place, or is there something wrong with my code? This is the relevant part of the config file:
<?xml version="1.0"?>
<config>
<modules>
<mymodule>
<version>1.0.0.0</version>
</mymodule>
</modules>
<global>
<resources>
<update_myscript>
<setup>
<module>mymodule</module>
</setup>
</update_myscript>
</resources>
</global>
</config>
And i created an update file: /updateMyscript/upgrade-1.0.0.0-1.0.0.1.php

If your module has been registered on core_resource, you need to delete from that, for the setup execute again.
And if you want update the module setup, you need to create that upgrade file (upgrade-1.0.0.0-1.0.0.1.php) and alter the version on config.xml
Like this:
<mymodule>
<version>1.0.0.1</version>
</mymodule>
After this you need clear cache from Magento.

Related

Book: "Getting Started with Magento Extension Development", sql migration script not executed

I have followed the same steps as mentioned in the Book, the key steps are:
create the resources setup configuration at <Module Directory>/etc/config.xml as follow:
<?xml version="1.0"?>
<config>
<global>
<modules>
<Foggyline_HappyHour>
<version>1.0.0.0</version>
</Foggyline_HappyHour>
</modules>
<!-- Some Other Configuration (Doesn't matter) -->
<resources>
<foggyline_happyhour_setup>
<setup>
<model>Foggyline_HappyHour</model>
</setup>
</foggyline_happyhour_setup>
</resources>
<!-- Some Other Configuration (Doesn't matter) -->
</global>
</config>
Create a the migration script at <Module Directory>/sql/foggyline_happyhour_setup/install-1.0.0.0.php with the following script:
<?php
// Just checking if the script is executed
echo 'Thank you for your help :)';
Load any pages and check if the page print the message.
Nope, it didn't print anything. The script didn't run at all.
How can we fix this?
:( Apparently there was a typo in the books ):
According to the official docs, the setup definition should be <module> instead of <model>. Thus:
<?xml version="1.0"?>
<config>
<global>
<!-- Some Other Configuration (Doesn't matter) -->
<resources>
<foggyline_happyhour_setup>
<setup>
<module>Foggyline_HappyHour</module>
</setup>
</foggyline_happyhour_setup>
</resources>
<!-- Some Other Configuration (Doesn't matter) -->
</global>
</config>
Now I can see the script executed. :)

Magento custom language file not being used

I have created a custom language file for a feature that I have built into our Magento website. The language variables work fine on my local machine (of course), however on our staging environment it doesn't. My local machine is Windows and staging server is Linux, so obvious answer would be an issue with filename casing, but imho these are right.
I have my own block that overwrites the Mage_Catalog, called Feno_Catalog which works fine. To that config.xml file I've appended some code to load the Feno_Catalog.csv;
/local/Feno/Catalog/etc/config.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<config>
<modules>
<Feno_Catalog>
<version>0.1.0</version>
</Feno_Catalog>
</modules>
<global>
<blocks>
<catalog>
<rewrite>
<class>Feno_Catalog_Block</class>
</rewrite>
</catalog>
</blocks>
<helpers>
<catalog>
<rewrite>
<class>Feno_Catalog_Helper</class>
</rewrite>
</catalog>
</helpers>
</global>
<frontend>
<translate>
<modules>
<Feno_Catalog>
<files>
<default>Feno_Catalog.csv</default>
</files>
</Feno_Catalog>
</modules>
</translate>
</frontend>
<adminhtml>
<translate>
<modules>
<Feno_Catalog>
<files>
<default>Feno_Catalog.csv</default>
</files>
</Feno_Catalog>
</modules>
</translate>
</adminhtml>
</config>
The CSV file has been put into 2 folders: /app/locale/[de_DE|en_US]/ with matching casing.
As I mentioned it works fine on my local machine, but not on the staging server. What could cause this? I've searched for quite a bit and cleared cache (although cache is turned off), switched languages (both languages don't work - The language keys are like "poll_question_a1").
When I move the translations to Mage_Catalog.csv everything also works fine (but of course that is not what I want).
So how to fix? Is there any way to find the cause of this?
Perhaps since you're rewriting the catalog module, you need your translates to look like this:
<translate>
<modules>
<Mage_Catalog>
<files>
<feno>Feno_Catalog.csv</feno> <!-- name it something other than default, to avoid conflict with Mage_Catalog -->
</files>
</Mage_Catalog>
</modules>
</translate>
Also, you can try looking in app/code/core/Mage/Core/Model/Translate.php around line 131-134. That is where it is loading your module translations. Try doing some Mage::log() calls in and around there to see if your CSV files are actually getting loaded.

Extending Mage Core Files Without Loosing Namespace

I would like to introduce my own entities into particular Magento module namespaces for example I might want to be able to call
Mage::getModel('catalog/brand')->load(1);
Brand is not currently a model included in the catalog module. I don't want to modify core files nor do I want to hack the core by just adding a Mage folder to the local directory.
I was thinking perhaps syntax inside of my namespaces config file similar to this:
<models>
<catalog>
<args>
<modules>
<AJW_Catalog before="Mage_Catalog">AJW_Catalog</AJW_Catalog>
</modules>
</args>
</catalog>
<ajw_catalog>
<class>AJW_Catalog_Model</class>
</ajw_catalog>
</models>
but it does not seem to work.
Does anyone know how this can be accomplished?
Maybe possible with some trickery, but not officially supported, and generally a bad idea. The before= syntax you've used only works for the routers node. There's no framework code to let you do what you're trying to do. Also, there's a strong bias in the Magento framework code towards individual modules "owning" their namespace/package name. Defining new models in an existing namespace (catalog) introduces the theoretical possibility that your code may conflicts with a future version of Magento's code.
This may be a possible fix (brain fart)
Create a module named Customnamespace_Catalog and then just rewrite the catalog module with a node that doesnt exist in the default mage module:
<?xml version="1.0"?>
<config>
<modules>
<Namespace_Catalog>
<version>0.1.0</version>
</Namespace_Catalog>
</modules>
<global>
<models>
<catalog>
<rewrite>
<brand>Namespace_Brand_Model_Brand</brand>
</rewrite>
</catalog>
</models>
</global>
</config>
Followed by an additional module:
<?xml version="1.0"?>
<config>
<modules>
<Namespace_Brand>
<version>0.1.0</version>
</Namespace_Brand>
</modules>
<global>
<models>
<brand>
<class>Namespace_Brand_Model</class>
</brand>
</models>
</global>
</config>
This will allow you to call Mage::getModel('catalog/brand')
echo get_class(Mage::getModel('catalog/brand'); // Namespace_Brand_Model_Brand

Unable to run a simple install script

I am trying to follow This tutorial, somewhat unsuccessfully!
I have got to the point where my script should display "Running This Upgrade: Myname_Weblog_Model_Resource_Setup Exit for now". This does not happen.
I believe it is something to do with my config file but looking though it I cannot work out what is wrong.
I have put a die statement into the setup.php file and that killed the script as expected. I then removed the die statement from setup.php and placed it into mysql4-install-0.1.0.php, this had no effect and the script continued on to render data from my controller.
I have added the code which I have been looking at to try and find the solution (as well as the full folder structure, hopefully its clear enough), could someone please advise me where the problem is or where else I should be looking to resolve this issue.
Myname
Weblog
Model
Resource
Blogpost
-Collection.php
-Blogpost.php
-Setup.php
-Blogpost.php
controllers
-IndexController.php
etc
-config.xml
sql
weblog_setup
-mysql4-install.0.1.0.php
Myname/Weblog/etc/config.xml
<config>
<modules>
<Tonysimpson_Weblog>
<version>0.1.0</version>
</Tonysimpson_Weblog>
</modules>
<global>
<models>
<weblog><!--group name, matches the module name-->
<class>Tonysimpson_Weblog_Model</class><!--Base name allmodels in the weblog group will have-->
<resourceModel>weblog_resource</resourceModel><!--indicagtes which resource model should be used-->
</weblog>
<weblog_resource>
<class>Tonysimpson_Weblog_Model_Resource</class>
<entities>
<blogpost>
<table>blog_posts</table>
</blogpost>
</entities>
</weblog_resource>
</models>
<resources>
<weblog_setup>
<setup>
<module>Tonysimpson_Weblog</module>
<class>Tonysimpson_Weblog_Model_Resource_Setup</class>
</setup>
</weblog_setup>
</resources>
</global>
<frontend>
<routers>
<weblog>
<use>standard</use>
<args>
<module>Tonysimpson_Weblog</module>
<frontName>weblog</frontName>
</args>
</weblog>
</routers>
</frontend>
MyName/Weblog/Model/Resource/Setup.php
class Tonysimpson_Weblog_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
{
}
Myname/Weblog/sql/weblog_setup/mysql4-install-0.1.0.php
echo 'running this upgrde: ' . get_class($this) . "\n <br /> \n";
die("exit for now");
checkout forweblog_setup in core_resoruce table, if your resource(weblog_setup) is present in this table than your installer will not run, what you can do is make an backup of your core_resource and delete its entry for weblog_setup OR else you can try to write an upgrade script.
You can try to delete setup class and see if there will be any error. So you will now then if config.xml is OK.
Also check in database the core_resoruce table or something like that. Maybe it's already installed and this is why it can't run again.
Also delete cache.
What server do you use ? ngnix or apache? Because I had a client that has the first one and there was some permission problem and because of that extensions didn't install.

Magento - Custom event module - Class not found error in system.log

I am trying to create a custom module which will capture order information each time a sales happens and will send that to a STOMP server. The idea is to create a realtime dashboard of sales events.
I've created the generic structure of the module and Magento is able to recognize it properly, but the code is not being executed. I've traced it down to the fact that Varien_Autoload cannot find my class.
My config is as follows:
app/etc/modules/PrettySecrets_SalesEvent.xml
<?xml version="1.0"?>
<config>
<modules>
<PrettySecrets_SalesEvent>
<active>true</active>
<codePool>local</codePool>
</PrettySecrets_SalesEvent>
</modules>
</config>
app/code/local/PrettySecrets/SalesEvent/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<PrettySecrets_SalesEvent>
<version>0.0.1</version>
</PrettySecrets_SalesEvent>
</modules>
<global>
<models>
<prettysecrets_salesevent>
<class>PrettySecrets_SalesEvent_Model</class>
</prettysecrets_salesevent>
</models>
<events>
<checkout_onepage_controller_success_action>
<observers>
<prettysecrets_salesevent>
<type>singleton</type>
<class>prettysecrets_salesevent/observer</class>
<method>doStreamToNode</method>
</prettysecrets_salesevent>
</observers>
</checkout_onepage_controller_success_action>
</events>
</global>
</config>
I'm given to believe that the directory structure is extremely important for Magento:
app
code
local
PrettySecrets
SalesEvent
etc
config.xml
Model
Observer.php
The system.log shows:
Warning: include(PrettySecrets_SalesEvent_Model_Observer.php): failed
to open stream: No such file or directory in
/chroot/home/.../includes/src/Varien_Autoload.php on line 93
I've also verified that app/code/local is in my path. Also, I've debugged it down into App.php with Mage::log inserts.
Any help would be much appreciated as I am literally tearing my hair out.
Thanks
Dude you have the Magento compiler enabled, disable this from system > tools > compilation as compilation copies your files to include/src/ folder and all your changes are left unseen by magento after that (before you recompile at least)

Resources