troubleshooting a hello world module - magento-1.7

I followed a tutorial from Alan Storm on creating a basic Hello World module for Magento. After some initial problems I got it working. Today I have gone to try and expand on that and the module no longer works(I get a 404 page not found message), I have not changed any code within that module or deleted any files.
The only thing that I can think I did since first creating the module and now is go into Magento's admin screen and make some adjustments - which i've tried changing back, but I still get the 404. I also have few other basic modules that I have been working on, but they also seem to no longer work.
I have checked System > Configuration > Advanced and the modules are all still enabled
Can anyone see something in my code that would stop this module from not being found when I vist http://magentotest.local/helloworld
app/etc/modules/As_Helloworld.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<As_Helloworld>
<active>true</active>
<codePool>local</codePool>
</As_Helloworld>
</modules>
</config>
app/code/local/As/Helloworld/controllers/IndexController.php
class As_Helloworld_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction() {
echo 'Hello Index!';
}
}
app/code/local/As/Helloworld/etc/config.xml
<config>
<modules>
<As_Helloworld>
<version>0.1.0</version>
</As_Helloworld>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>As_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
</config>
1-Would changing options in the admin area be able to stop a module working?
2-If so where do I start looking to fix the problem
3-What can I do to prevent it from happening again?

Related

My custom extension is not visible on admin panel Magento 2.0

I installed my custom extension via composer.
I can confirm that app/code/vendor/package_name generated on the server by composer.
However,on admin panel under stores/configuration/advanced I can not see my extension.
What I've tried so far are as following ;
Flushing Magento 2.0 cache and disabling caching
Changing extension file permissions to 777
Deleting files under var/cache manually
Logging out and logging in again
None of them solved my problem.
How can I see my custom extension under admin stores / configuration / advanced on Magento 2.0 ?
I am not sure if it any helps but I posted my config.xml and module.xml
Thanks in advance,
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Fusion_CODFee" schema_version="0.0.1"></module>
</config>
<?xml version="1.0" ?>
<config>
<modules>
<Fusion_CODFee>
<version>0.1.0</version>
</Fusion_CODFee>
</modules>
</config>
According to me setup_version is missing from module.xml. It should be like this :
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Fusion_CODFee" schema_version="0.0.1" setup_version="0.0.1"></module>
</config>
you shoul try php bin/magento setup:upgrade command so that your magento upgrade itself with the new extension, also check for config.php in app/etc folder ,your module should be there if is active in case it is not then under array() tag add this "Fusion_CODFee=>1" and then run upgrade command in your rootdirectory, it might help you.
I've tried following code that's working for me please have look
Fusion\CODFee\etc\module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Fusion_CODFee" setup_version="2.0.0">
</module>
</config>
Now next you have to register your module with registration.php
create registration.php under Fusion\CODFee\registration.php and put below code inside it.
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Fusion_CODFee',
__DIR__
);
Now clearing you cache and if still not working then fire below command from your root directory of magento installation
If your system is ubuntu then => sudo php bin\magento setup:upgrade or for window system remove sudo
then change permission and that's it
Let me know if still have any query

Overwriting a Magento core class using custom module

I encouraged to post a question here for the first time, so here it goes!
I'm trying to overwrite Magento core class for the first time; Mage_CatalogInventory_Model_Stock_Item located # /app/code/core/Mage/CatalogInventory/Model/Stock/Item.php, but for some reason I'm not having any success as executing;
$object = Mage::getModel('cataloginventory/stock_item');
var_dump(get_class($object));
outputs
string 'Mage_CatalogInventory_Model_Stock_Item' (length=38)
I created a new directory under /app/code/local/Rage and copied the Item.php to /app/code/local/Rage/CatalogInventory/Model/Stock/Item.php renaming it to
class Rage_CatalogInventory_Model_Stock_Item extends Mage_CatalogInventory_Model_Stock_Item { ... }
I also made a couple of xml files. One to app/etc/modules/Rage_CatalogInventory.xml, which contains following;
<?xml version="1.0"?>
<config>
<modules>
<Rage_CatalogInventory>
<active>true</active>
<codepool>local</codepool>
</Rage_CatalogInventory>
</modules>
</config>
and another to app/code/local/Rage/CatalogInventory/etc/config.xml;
<?xml version="1.0" ?>
<config>
<modules>
<rage_cataloginventory>
<version>0.0.1</version>
</rage_cataloginventory>
</modules>
<global>
<models>
<cataloginventory>
<rewrite>
<stock_item>Rage_CatalogInventory_Model_Stock_Item</stock_item>
</rewrite>
</cataloginventory>
</models>
</global>
</config>
I just can't make it work even after a couple of hours trying... This is driving me crazy. Hope you can help me out!
Many many thanks in advance.
EDIT: Fixed config.xml as Amit pointed out. It turned out that Magento had compiler in use. I figured out that could've something to this. So disabled that and cleared the includes/src -folder contents, but still nothing is happening...
issue in config.xml and here rage_cataloginventory should be Rage_CatalogInventory and here total config.xml
<?xml version="1.0" ?>
<config>
<modules>
<Rage_CatalogInventory>
<version>0.0.1</version>
</Rage_CatalogInventory>
</modules>
<global>
<models>
<cataloginventory>
<rewrite>
<stock_item>Rage_CatalogInventory_Model_Stock_Item</stock_item>
</rewrite>
</cataloginventory>
</models>
</global>
</config>
Ok, this is just a guess and don´t be mad if i pointed something out that was clear to you;)
However: You did clear the config-cache, right?
(And keep the compiler disabled for development-environment, that saves you from some trouble if you forget that you have it active.)
The xml so far looks very correct to me, so that shouldn´t be the issue.
What to check:
Is the module loaded at all? (See under System->Config->Advanced)?
Is it working with any other model or just this one?
Any log output that gives a hint as to maybe the config.xml has an error (hidden chars etc.)?

Magento does not recognize new module

i tried like all tutorials out there and i still cannot get a custom created module to work in Magento.
This is the path where i created the XML file on the server to tell Magento what the module is:
app/etc/modules/Multiplies_HelloWorld.xml
<?xml version="1.0"?>
<config>
<modules>
<Multiplies_HelloWorld>
<active>true</active>
<codePool>local</codePool>
</Multiplies_HelloWorld>
</modules>
</config>
This is the module path:
app/code/local/Multiplies/HelloWorld/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Multiplies_HelloWorld>
<version>0.0.1</version>
</Multiplies_HelloWorld>
</modules>
</config>
when i go to System/Configuration/Advanced i see a whole bunch of other modules except mine.
I tried to flush the cash, disable it, clear it manualy, restart browser, relog but still no module in my list.
The version im using is magento 1.7.0.2 (free)
Im using FileZilla to upload files.
Any suggestions would be really appreciated.
This may be a bit late, but I was just having this same problem.
After 20 minutes of chin scratching I tried resetting all caches (System > Cache Management) and then it popped up!
I'm disabling the "configuration" cache while heavily developing a module. I think that'll help reduce friction.
Make sure your etc/module.xml looks like this:
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="OrgName_ModuleName" setup_version="1.0.0">
</module>
</config>
Make sure your composer.json has this:
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"OrgName\\ModuleName\\": ""
}
}
Make sure your registration.php looks like this:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'OrgName_ModuleName',
isset($file) && realpath($file) == __FILE__ ? dirname($file) : __DIR__
);
If your module is contained in a symlinked directory that is outside of magento root directory (happens when you use local "path": as a module's repository description in composer), you have to allow magento for symlinks with: bin/magento config:set dev/template/allow_symlink 1 . See https://magento.stackexchange.com/a/315525/88882 for more info.

How to compile on save?

I would like to compile the project every time I save, but in properties this option is greyed, so for any change I do I have to click save then clean and build.
How can I do to avoid to clean and build for every code modification?
Change your netbeans project's project.properties like below.
Find below line in project.properties file
compile.on.save.unsupported.javafx=true
Change this value to set to false
compile.on.save.unsupported.javafx=false
After change this file, compile on save option will be enabled and you are good to go.
Answer for Apache NetBeans 9, 10, 11 using Maven.
Configuration is set at nbactions.xml file, usually it'll look similar to this:
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>war</packaging>
<packaging>ear</packaging>
<packaging>ejb</packaging>
</packagings>
<goals>
<goal>package</goal>
</goals>
</action>
</actions>
To activate the Compile On Save option you only need to add the <netbeans.compile.on.save> setted to all, it'll look like this:
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>war</packaging>
<packaging>ear</packaging>
<packaging>ejb</packaging>
</packagings>
<goals>
<goal>package</goal>
</goals>
<properties>
<netbeans.compile.on.save>all</netbeans.compile.on.save>
</properties>
</action>
</actions>
Also...
At latest NB 10 and 11 you may see the warning It is recommended to install nb-javac Library to improve Java editing experience and enable compile on save at Notifications section:
You just need to install that plug-in (nb-javac) by clicking on that link, more info here, there's currently an open issue for NB11.2, if you have problems with it try using beta 3 (or latest)
You should choose the Sources rather than Build from the Categories.

Beginner Steps to Configure a Java Project to Build with Apache Maven

I've been given the task of migrating an existing project -- formerly built with Ant -- to use Apache Maven. I'm brand new to the entire concept, though I've spent the last several hours doing as much research as I can on the subject. Sadly, I'm having some proxy issues when it comes to installing things like m2e and Eclipse IAM, so everything must be done from the command prompt. As of right now, I do have maven installed properly; the trick now is to use it in my project rather than Ant. I've looked online and found a few tutorials, but they are all too vague for me considering my lack of experience with all of this. If anyone can break the steps down for me one-by-one in a detailed manner, that would be more than amazing. On a side note, I've been told to add the following to the local Maven Settings:
<settings>
<servers>
<server>
<id>local_tomcat</id>
<username>admin</username>
<password>tomcat</password>
</server>
<server>
<id>artifactory</id>
<username>user</username>
<password>password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>artifactory</id>
<name>Artifactory</name>
<url>https://jenkins.web.jw.local/artifactory/repo1</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.jw.local</host>
<port>80</port>
<username>user</username>
<password>password</password>
<nonProxyHosts>*.jw.local</nonProxyHosts>
</proxy>
</proxies>
</settings>
With the obvious username and password information filled in. I think I've managed that thus far by simply adding the necessary blocks into the settings.xml file under my ApacheMaven\conf directory. Other than that single step, I'm pretty much lost. Again, any help, especially that of a detailed tutorial in terms of command line instructions to build this project would be wonderful. Oh, and on another side-note, I am using Eclipse... Not sure if that would matter much.
EDIT: Considering Petr Kozelka's answer, I've attempted to make a pom.xml file for my project. Here's what I have so far...
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>appName</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>Application Name</name>
<description>Yadda Yadda</description>
<build>
<plugins>
</plugins>
</build>
<dependencies>
</dependencies>
<repositories>
</repositories>
</project>
Is this heading in the right direction? Also, do I need to construct the archetype.xml file myself, or will Maven do that through the command line somehow? If I need to do it myself, this is what I've come up with thus far:
<archetype xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
<id>lighthouse</id>
<sources>
<source>src/com/jeldwen/lighthouse/controller/AddTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/BugController.java</source>
<source>src/com/jeldwen/lighthouse/controller/DeleteTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/EnterTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/ModifyTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/PersonController.java</source>
<source>src/com/jeldwen/lighthouse/controller/ProjectController.java</source>
<source>src/com/jeldwen/lighthouse/controller/TimeController.java</source>
<source>src/com/jeldwen/lighthouse/model/Area.java</source>
<source>src/com/jeldwen/lighthouse/model/Bug.java</source>
<source>src/com/jeldwen/lighthouse/model/DBModel.java</source>
<source>src/com/jeldwen/lighthouse/model/DefaultModel.java</source>
<source>src/com/jeldwen/lighthouse/model/JWModel.java</source>
<source>src/com/jeldwen/lighthouse/model/JWTime.java</source>
<source>src/com/jeldwen/lighthouse/model/Person.java</source>
<source>src/com/jeldwen/lighthouse/model/Project.java</source>
<source>src/com/jeldwen/lighthouse/util/Lighthouse.java</source>
<source>src/com/jeldwen/lighthouse/util/LighthouseApplicationListener.java</source>
<source>src/com/jeldwen/lighthouse/util/LighthouseServlet.java</source>
<source>src/com/jeldwen/lighthouse/util/LighthouseSystemProperties.java</source>
<source>src/com/jeldwen/lighthouse/LighthouseApp.java</source>
</sources>
<testSources>
<!-- None -->
</testSources>
<allowPartial>true</allowPartial>
</archetype>
First of all: if you wish to customize settings.xml, do not touch the one in maven distro - instead, create a new file in $HOME/.m2/settings.xml where maven finds and uses it.
As the very first step, I recommend you to not use settings.xml at all.
Create a supersimple maven project, and try to compile it:
mvn clean install
Second step
Use very simple settings.xml:
you probably do not need proxy
servers part is needed only for publishing artifacts to a maven repository; that's not important at the beginning
here it is:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<id>repos</id>
<mirrorOf>*</mirrorOf>
<name>internal mirror</name>
<url>https://jenkins.web.jw.local/artifactory/repo1</url>
</mirror>
</mirrors>
<!-- TODO: the proxy part here -->
</settings>
This assumes that you use inhouse maven repository, for instance Nexus or Artifactory.
Using maven repo makes only sense if your projects are not happy with deps available in the Maven Central Repository - otherwise, you can safely go without it. (let's neglect the performance effect of repoman for now)
Now, add some java sources, dependencies etc. - and watch how new depenencies get automatically downloaded to your local repository...
Third step
Learn how to add further repositories to your repository manager (group "public" on Nexus)...
The rest is probably subject of further research.