Unable to run a simple install script - magento

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.

Related

Magento module not added to core_resource table

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.

Magento Extension causes 404 Error from the Admin Panel

We have a Magento Extension on our website, written by an ex-employee. This extension was written just for this one website, and I am struggling to find out what is going wrong with this extension. Contacting the ex-employee has proven to be (how should I put this), an ineffective method for solving this problem, so I was hoping someone here could help me out.
The extension works fine on the site, but when we click on the extension in the backend, on the Admin Panel, we get a "404 Not Found 1" error.
Is there anything I can do (like changing log file settings) to find out what file is missing and causing this 404?
QUICK UPDATE
After rolling back a load of patches we have noticed that this problem only occurs after patch 5994. Is there anything in patch 5994 that could be causing these problems?
The extension itself has the following files:
\app\code\local\muz\Worldman\controllers\
WorldmanController.php
\app\code\local\muz\Worldman\controllers\Adminhtml\
WorldmanController.php
\app\code\local\muz\Worldman\controllers\etc
config.xml
\app\code\local\muz\Worldman\controllers\Helper
Data.php
I can make changes to the class names in the \app\code\local\muz\Worldman\controllers\Adminhtml\WorldmanController.php and instead of getting a 404 error, I get an actual crash report, stating that Controller file was loaded but class does not exist.
Again, this extension works fine on the site itself. Its just clicking on the extension itself from the Admin Panel menu that causes the 404.
The extension is enabled. I have logged out and back in a hundred times. Indexes have been re-indexed. Caches have been cleared and turned off. Servers have been rebooted. But to no avail.
At this point any suggestions for debugging any Magento extensions would be very much appreciated.
If this helps, here is the config.xml file:
<?xml version="1.0"?>
<config>
<modules>
<muz_Worldman>
<version>1.0.0</version>
</muz_Worldman>
</modules>
<global>
<helpers>
<worldman>
<class>muz_Worldman_Helper</class>
</worldman>
</helpers>
</global>
<frontend>
<routers>
<worldman>
<use>standard</use>
<args>
<module>muz_Worldman</module>
<frontName>worldman</frontName>
</args>
</worldman>
</routers>
<layout>
<updates>
<worldman>
<file>worldman.xml</file>
</worldman>
</updates>
</layout>
</frontend>
<adminhtml>
<menu>
<cms>
<children>
<worldman_adminform translate="title" module="worldman">
<title>Worldman Manager</title>
<action>worldman/adminhtml_worldman</action>
</worldman_adminform>
</children>
</cms>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<cms>
<children>
<worldman_adminform>
<title>worldman Manager</title>
</worldman_adminform>
</children>
</cms>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<worldman>
<file>worldman.xml</file>
</worldman>
</updates>
</layout>
</adminhtml>
</config>
The ACL settings are not set right for the user, that's why you get a 404. Even with the ACL set correctly you might get this error if you do not flush the Magento config cache and log out and then back in again.
From a quick look at your config, it seems like the XML part of the ACL settings is alright, but you might need to check if the file \app\code\local\muz\Worldman\controllers\Adminhtml\WorldmanController.php has a method like this in it:
protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('cms/worldman_adminform');
}
I had a bunch of modules that stopped working because of this missing method after one of Magento's latest patches.
Also, did you try with an admin account where you should automatically have full access?
--------EDIT-------
The patch you mentioned (5994) gave me similar problems with one of my modules. It used frontend routing for the adminhtml-controller, so what I had to do was to remove the XML between <frontend>...</frontend> and replace it with something like this:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<muz_Worldman after="Mage_Adminhtml">muz_Worldman_Adminhtml</muz_Worldman>
</modules>
</args>
</adminhtml>
<worldman>
<use>admin</use>
<args>
<module>muz_Worldman</module>
<frontName>worldman</frontName>
</args>
</worldman>
</routers>
</admin>
and also make sure that the the XML for ACL action - <action>worldman/adminhtml_worldman</action> is right, I had to make some changes to the URL so mine became more like (for you) adminhtml/worldman_adminform.

Magento helper methods do not work

So this one is a bit odd. I'm sure it's old hat to some now, and I've just done a bad job searching it out. If that's the case I certainly apologize and ask for your indulgence and a link to the already provided answer.
So I have followed the core guides for creating a magento module, but for some reason it does work right. When I var_dump the helper class it has the correct name, but when I try to use one of the methods I've put in the class definition it throws an exception.
Furthermore, when I run get_class_methods() on the class given to me by Mage::helper('mymodule/myhelper') none of my methods are there.
So in summary:
The class is in the right place, app/code/local/MyModule/Helper/Myhelper.php
The class shows as initialized after I call Mage::helper('mymodule/myhelper')
The class methods are not listed, and as a result, break things when called.
Here's my config for reference. The rest of the module seems to be fine.
<?xml version="1.0"?>
<config>
<modules>
<APCShared_Shipping>
<version>0.1.0</version>
</APCShared_Shipping>
</modules>
<frontend>
<routers>
<apcshipping>
<use>standard</use>
<args>
<module>APCShared_Shipping</module>
<frontName>apcshipping</frontName>
</args>
</apcshipping>
</routers>
</frontend>
<global>
<blocks>
<apcshipping>
<class>APCShared_Shipping_Block</class>
</apcshipping>
</blocks>
<helpers>
<apcshipping>
<class>APCShared_Shipping_Helper</class>
</apcshipping>
</helpers>
<models>
<apcshipping>
<class>APCShared_Shipping_Model</class>
<resourceModel>shipping_resource</resourceModel>
</apcshipping>
<apcshipping_resource>
<class>APCShared_Shipping_Model_Resource</class>
<entities>
<zipcode>
<table>apc_shipping_zipcode</table>
</zipcode>
</entities>
</apcshipping_resource>
</models>
</global>
</config>
In the admin somewhere under System > Configuration > Advanced ensure your module has been registered.``
Make sure you have the class APCShared_Shipping_Helper_Data in the Helpers folder in a file called Data.php. Your class should extend Mage_Core_Helper_Abstract
Access your helper with Mage::helper('apcshipping')
Your directory structure should be something like:
- Module Folder
- etc
- config.xml
- Helper
- Data.php
In your file structure, point 1 of your summary, you are only using a modulename, not a packagename.
So it should be: app/code/local/MyCompany/MyModule/Helper/Myhelper.php instead of app/code/local/MyModule/Helper/Myhelper.php.
I'm not sure if this will make a difference, but it's always good to follow the coding convention.

Custom menu gives 404 in magento on server

I created a custom menu in admin tab in magento admin. It was working perfectly on localhost, but when i deployed my code on the server, it is giving a 404 page not found error. What can be the issue there!
<?xml version="1.0"?>
<config>
<modules>
<Inchoo_CoffeeFreak>
<version>0.1.0</version>
</Inchoo_CoffeeFreak>
</modules>
<global>
<blocks>
<coffefreakblock1>
<class>Inchoo_CoffeeFreak_Block</class>
</coffefreakblock1>
<coffefreakblock2>
<class>Inchoo_CoffeeFreak_Block_EditSpecial</class>
</coffefreakblock2>
</blocks>
<helpers>
<coffefreakhelper1>
<class>Inchoo_CoffeeFreak_Helper</class>
</coffefreakhelper1>
</helpers>
</global>
<admin>
<routers>
<samplerouter1>
<use>admin</use>
<args>
<module>Inchoo_CoffeeFreak_AdminControllersHere</module>
<frontName>print</frontName>
<modules>
<sintax after="Inchoo_CoffeeFreak_AdminControllersHere">Mage_Adminhtml</sintax>
</modules>
</args>
</samplerouter1>
</routers>
</admin>
<adminhtml>
<menu>
<mymenu1 translate="title" module="coffefreakhelper1">
<title>PrintInfo</title>
<sort_order>20</sort_order>
<children>
<!-- Note the misleading "module" attribute.
It actualy refers to one of the declared helpers -->
<myitem1 translate="title" module="coffefreakhelper1">
<title>Add/Change Config</title>
<action>samplerouter1/settings</action>
<sort_order>1</sort_order>
</myitem1>
</children>
</mymenu1>
</menu>
</adminhtml>
</config>
Your server may be running on Linux which is case sensitive so you need to check that you module file and folder should be according Magento standard like controller should be IndexController not indexController etc.
and your localhost running on window which is not case sensitive.
Normally this is when you are logged in. Logout and login again. Then it should work.
Assuming that cache is turn off / cleared
1) Logout and log back in again
If you still getting a 404 error
2) Check your server error log, you maybe missing your module helper file
Login In/Out,clear cache, should be the solution.But you can try below points (though it may find foolish).
1) Check your xml contents.(line by line with your localhost xml)
2) Spellings matter (hope <sintax> spelling is correct is your xml )
3) Remove unwanted space (like before <global> tag) and comments.
4) Opening & closing of tags.
5) Proper Indentation (this will help to find your flaw if it is there)
6) Atlast directly copy the same localhost xml file in your server.
I really wish this will help you to find the bug.

Magento controller override

I am trying to overwrite a controller of an extension....that is overwriting the cart controller.
The extension currently overwriting the cart controller is:
Innoexts/Warehouse/controllers/Checkout/CartController.php
The config entry in the Innoexts module doing this is:
<frontend>
<routers>
<checkout>
<args>
<modules>
<Innoexts_Warehouse before="Mage_Checkout">Innoexts_Warehouse_Checkout</Innoexts_Warehouse>
</modules>
</args>
</checkout>
</routers>
...blah...blah...
</frontend>
The top of the innoext cartcontroller file is:
require_once 'Mage/Checkout/controllers/CartController.php';
class Innoexts_Warehouse_Checkout_CartController extends Mage_Checkout_CartController {
I want to overwrite it with this controller:
Myco/Warehousemod/controllers/Checkout/CartController.php
The top of the controller file is:
require_once 'Innoexts/Warehouse/controllers/Checkout/CartController.php';
class Myco_Warehousemod_Checkout_CartController extends Innoexts_Warehouse_Checkout_CartController {
The config entry ive created is:
<global>
...blah...blah...
<rewrite>
<myco_warehousemod_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/warehousemod/checkout_cart/</to>
</myco_warehousemod_checkout_cart>
</rewrite>
</global>
<frontend>
<routers>
<checkout>
<args>
<modules>
<Myco_Warehousemod before="Innoexts_Warehouse_Checkout">Myco_Warehousemod_Checkout</Myco_Warehousemod>
</modules>
</args>
</checkout>
</routers>
...blah...blah...
</frontend>
I am getting a 404 not found error for the checkout/cart URL now....Can anyone see where im going wrong? Online resources are very different...and confusing!! The issue may be with me trying to overwrite an overwriting controller...??
thanks in advance...
Need to remove the first rewrite:
<rewrite>
<myco_warehousemod_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/warehousemod/checkout_cart/</to>
</myco_warehousemod_checkout_cart>
</rewrite>
I think certain people should stop writing tutorials....cluttering up the web with their half-assed SEO efforts....
This part was used in the old versions of Magento (i think before 1.4), but if you want to extend a controller that has a rewrite like this in the config file, you have to do the same in your config.
<rewrite>
<myco_warehousemod_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/warehousemod/checkout_cart/</to>
</myco_warehousemod_checkout_cart>
</rewrite>
The new versions use only the part with before so you should have something like this:
<routers>
<checkout>
<args>
<modules>
<Myco_Warehousemod before="Innoexts_Warehouse">Myco_Warehousemod_Checkout</Myco_Warehousemod><!-- just the name of the module Innoexts_Warehouse the overridden folder will be taken from the part after the name of your module so Magento will look in app/local/Myco/Warehousemod/controllers/Checkout/* and load all the controllers from there -->
</modules>
</args>
</checkout>
</routers>
Just an additional notes for those who wants to know about confliction between extensions and possible solutions(just like above case), refer to the following links:
http://www.webshopapps.com/blog/2010/11/resolving-magento-extension-conflicts/
http://sweettoothrewards.com/wiki/index.php/Resolving_extension_conflicts
http://magebase.com/magento-tutorials/magento-extension-clashes-winners-and-loosers/
http://www.magestore.com/blog/2011/12/21/magento-methods-to-resolve-the-module-conflicts-in-magento/
This is a little notification on the include path of the controller.
This include path can cause errors if the Magento Compiler mode is turned on.
require_once 'Mage/Checkout/controllers/CartController.php';
Instead of that it is good to use
require_once Mage::getModuleDir('controllers', 'Mage_Checkout').DS.'CartController.php';
It will be safer.

Resources