Ive made a custom module in magento. The Admin panel recognises it but not the store.. Ive checked many posts and sources but nothing solves my problem
Code In the app/etc/modules/Firstmagetest_All.xml:
<?xml version = "1.0"?>
<config>
<modules>
<Firstmagetest_Test>
<active>true</active>
<codePool>local</codePool>
</Firstmagetest_Test>
</modules>
</config>
Code in app/code/local/FirstMageTest/Test/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Firstmagetest_Test>
<version>1.0.0</version>
</Firstmagetest_Test>
</modules>
<frontend>
<routers>
<firstmage_test>
<use>standard</use>
<args>
<module>Firstmagetest_Test</module>
<frontName>test</frontName>
</args>
</firstmage_test>
</routers>
</frontend>
</config>
[html]
Code in app/code/local/FirstMageTest/Test/controllers/IndexController.php
<?php
class Firstmagetest_Test_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction ()
{
echo 'test index';
}
public function mamethodeAction ()
{
echo 'test mymethod';
}
}
?>
Related
Try to override model of Mage_Paypal_Model_Express_Checkout but not working.
I try to override start() in "Mage_Paypal_Model_Express_Checkout" in magento.
The bellow code used but not working.
File : code/local/Live/Paypal/Model/Express/Checkout.php
class Live_Paypal_Model_Express_Checkout extends
Mage_Paypal_Model_Express_Checkout
{
public function start($returnUrl, $cancelUrl, $button = null)
{
echo "fasdfasdf";exit;
}
}
File : code/local/Live/Paypal/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Live_Paypal>
<version>1.0.0</version>
</Live_Paypal>
</modules>
<global>
<models>
<paypal>
<rewrite>
<express_checkout>Live_Paypal_Model_Express_Checkout</express_checkout>
</rewrite>
</paypal>
</models>
</global>
</config>
File : app/etc/modules/Live_Paypal.xml
<?xml version="1.0"?>
<config>
<modules>
<Live_Paypal>
<active>true</active>
<codePool>local</codePool>
</Live_Paypal>
</modules>
</config>
Hi i am trying to override magento wishlist IndexController. I have followed all steps but its not working here is my code and path of all directories
app\code\local\XS4Arabia\Wishlist\etc\config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<XS4Arabia_Wishlist>
<version>0.1.0</version>
</XS4Arabia_Wishlist>
</modules>
<frontend>
<routers>
<wishlist>
<args>
<modules>
<XS4Arabia_Wishlist before="Mage_Wishlist">XS4Arabia_Wishlist</XS4Arabia_Wishlist>
</modules>
</args>
</wishlist>
</routers>
</frontend>
</config>
app\code\local\XS4Arabia\Wishlist\controllers\IndexController.php
require_once Mage::getModuleDir('controllers', 'Mage_Wishlist') . DS . 'IndexController.php';
class XS4Arabia_Wishlist_IndexController extends Mage_Wishlist_IndexController
{
public function sendAction()
{
die('local');
}
}
app\etc\modules\XS4arabia_Wishlist.xml
<?xml version="1.0"?>
<config>
<modules>
<XS4Arabia_Wishlist>
<active>true</active>
<codePool>local</codePool>
</XS4Arabia_Wishlist>
</modules>
</config>
I need to override the stockAction() in the AddController.php of code/core/Mage/ProductAlert/controllers. So I searched a lot to see how to proceed, and got this:
/etc/modules/Totem_ProductAlert.xml
<?xml version="1.0"?>
<config>
<modules>
<Totem_ProductAlert>
<active>true</active>
<codepool>local</codepool>
</Totem_ProductAlert>
</modules>
</config>
/code/local/Totem/ProductAlert/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Totem_ProductAlert>
<version>0.0.1</version>
</Totem_ProductAlert>
</modules>
<frontend>
<routers>
<productalert>
<args>
<modules>
<Totem_ProductAlert before="Mage_ProductAlert">Totem_ProductAlert</Totem_ProductAlert>
</modules>
</args>
</productalert>
</routers>
</frontend>
</config>
/code/local/Totem/ProductAlert/controllers/AddController.php
class Totem_ProductAlert_AddController extends Mage_ProductAlert_AddController
{
public function stockAction()
{
Mage::log('test', null, 'Test.log');
}
But the action is not overriden and no Test.log has been created.
Somebody knows where I fucked up ?
Thanks.
There are issue in your code:
A syntax issue in Totem_ProductAlert.xml. <codepool> should
be <codePool> .p should be capital letter.
<?xml version="1.0"?>
<config>
<modules>
<Totem_ProductAlert>
<active>true</active>
<codePool>local</codePool>
<depends>Mage_ProductAlert</depends>
</Totem_ProductAlert>
</modules>
</config>
Require to call properly include Core AddController.php at
Totem_ProductAlert_AddController class
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of AddController
*
* #author work
*/
require_once Mage::getModuleDir('controllers', 'Mage_ProductAlert').DS.'AddController.php';
class Totem_ProductAlert_AddController extends Mage_ProductAlert_AddController
{
public function stockAction()
{
Mage::log('test', null, 'Test.log',true);
}
}
try this
<?xml version="1.0"?>
<config>
<modules>
<Totem_ProductAlert>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Totem_Custom>
</modules>
</config>
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Totem_ProductAlert>
<version>0.1.0</version>
</Totem_ProductAlert>
</modules>
<frontend>
<routers>
<productalert>
<use>standard</use>
<args>
<module>Totem_ProductAlert</module>
<frontName>productalert</frontName>
</args>
</productalert>
</routers>
</frontend>
<global>
<rewrite>
<totem_productalert_productalert_addcontroller>
<from><![CDATA[#^/productalert/add/#]]></from> <!-- Mage_ProductAlert_AddController -->
<to>/productalert/productalert_add/</to> <!-- Totem_ProductAlert_ProductAlert_AddController -->
</totem_productalert_productalert_addcontroller>
</rewrite>
<helpers>
<productalert>
<class>Totem_ProductAlert_Helper</class>
</productalert>
</helpers>
</global>
<admin>
<routers>
<productalert>
<use>admin</use>
<args>
<module>Totem_ProductAlert</module>
<frontName>admin_productalert</frontName>
</args>
</productalert>
</routers>
</admin>
</config>
Controller
<?php
require_once "Mage/ProductAlert/controllers/AddController.php";
class Totem_ProductAlert_ProductAlert_AddController extends Mage_ProductAlert_AddController{
public function stockAction(){
Mage::log('test', null, 'Test.log');
}
}
I know this has been asked a few times on here, but I've been through the answers and still can't figure out why I can't override a core model in Magento:
I am trying to override the Eav/Attribute/Data/Text.php but it refuses to use my version of the validateValue() function.
Here is my model class /app/code/local/Hailstorm/Eav/Model/Attribute/Data/Text.php
class Hailstorm_Eav_Model_Attribute_Data_Text extends Mage_Eav_Model_Attribute_Data_Text {
public function validateValue($value) {
$attribute = $this->getAttribute();
echo "My validator for |" . $attribute->getAttributeCode() . "|!\n";
if ($attribute->getAttributeCode() == 'postcode') {
$countryId = $this->getExtractedData('country_id');
$optionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
if (!in_array($countryId, $optionalZip)) {
return parent::validateValue($value);
}
return true;
}
else {
return parent::validateValue($value);
}
}
}
Here is my config.xml /app/code/local/Hailstorm/Eav/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<hailstorm_eav>
<version>0.1.0</version>
</hailstorm_eav>
</modules>
<global>
<models>
<eav>
<rewrite>
<attribute_data_text>Hailstorm_Eav_Model_Attribute_Data_Text</attribute_data_text>
</rewrite>
</eav>
</models>
<hailstorm_eav>
<class>Hailstorm_Eav_Model</class>
</hailstorm_eav>
</global>
</config>
And here is my module xml file
/app/etc/modules/Hailstorm_Eav.xml
<?xml version="1.0"?>
<config>
<modules>
<hailstorm_eav>
<active>true</active>
<codepool>local</codepool>
</hailstorm_eav>
</modules>
</config>
I've been through the tutorials and the answers to other questions like this on here, but I can't see what I'm doing wrong!
Thanks for any help
Use this
<codePool>local</codePool>
There are issue in class declaration of config.xml and Hailstorm_Eav.xml
in Hailstorm_Eav.xml
hailstorm_eav to Hailstorm_Eav
and in config.xml
<hailstorm_eav>
<version>0.1.0</version>
</hailstorm_eav>
Should be
<Hailstorm_Eav>
<version>0.1.0</version>
</Hailstorm_Eav>
And codePool syntax as Vishal Sharma Said
I start study magento from Magento for Developers guide. So I create module with their names. But it is showing following error when i trying http://works.dev/magento/?showConfig=true.
XML Parsing Error: XML or text declaration not at start of entity
Location: http://works.dev/magento/?showConfig=true
Line Number 1, Column 2: <?xml version="1.0"?>
-^
(works.dev is my localhost domain. magento path is working fine.)
This is my configuration files.
app/code/local/Magentotutorial/Configviewer/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Magentotutorial_Configviewer>
<version>0.1.0</version>
</Magentotutorial_Configviewer>
</modules>
<global>
<events>
<controller_front_init_routers>
<observers>
<Magentotutorial_configviewer_model_observer>
<type>singleton</type>
<class>Magentotutorial_Configviewer_Model_Observer</class>
<method>checkForConfigRequest</method>
</Magentotutorial_configviewer_model_observer>
</observers>
</controller_front_init_routers>
</events>
</global>
</config>
app/etc/modules/Magentotutorial_Configviewer.xml
<?xml version="1.0"?>
<config>
<modules>
<Magentotutorial_Configviewer>
<active>true</active>
<codePool>local</codePool>
</Magentotutorial_Configviewer>
</modules>
</config>
app/code/local/Magentotutorial/Configviewer/Model/Observer.php
<?php
class Magentotutorial_Configviewer_Model_Observer {
const FLAG_SHOW_CONFIG = 'showConfig';
const FLAG_SHOW_CONFIG_FORMAT = 'showConfigFormat';
private $request;
public function checkForConfigRequest($observer) {
$this->request = $observer->getEvent()->getData('front')->getRequest();
if($this->request->{self::FLAG_SHOW_CONFIG} === 'true'){
$this->setHeader();
$this->outputConfig();
}
}
private function setHeader() {
$format = isset($this->request->{self::FLAG_SHOW_CONFIG_FORMAT}) ?
$this->request->{self::FLAG_SHOW_CONFIG_FORMAT} : 'xml';
switch($format){
case 'text':
header("Content-Type: text/plain");
break;
default:
header("Content-Type: text/xml");
}
}
private function outputConfig() {
die(Mage::app()->getConfig()->getNode()->asXML());
}
}
I did clear cache and check logs. I cant find problem from those.
According #Jürgen Thelen it was space issue. It had worked after remove space before the
Ausuraya,can you please change config.xml
<global>
<models>
<configviewer>
<class>Magentotutorial_Configviewer_Model</class>
</configviewer>
</models>
<events>
<controller_front_init_routers>
<observers>
<Magentotutorial_configviewer_model_observer>
<type>singleton</type>
<class>configviewer/observer</class>
<method>checkForConfigRequest</method>
</Magentotutorial_configviewer_model_observer>
</observers>
</controller_front_init_routers>
</events>
</global>