Adding Data.php Helper in Magento got error - configuration

Following Alan Storm Tutorial in Custom Magento System Configuration, When i tried adding
the Data.php in the helper folder i still get this error:
Fatal error: Class 'Mage_Helloworld_Helper_Data' not found in E:\xampp\htdocs\magento
\app\Mage.php on line 520
**Alanstormdotcom\Helloworld\Helper\Data.php**
<?php
class Alanstormdotcom_Helloworld_Helper_Data extends Mage_Core_Helper_Abstract
{
}
**Alanstormdotcom\Helloworld\etc\system.xml**
<?xml version="1.0"?>
<config>
<tabs>
<helloconfig translate="label" module="helloworld">
<label>Hello Config</label>
<sort_order>99999</sort_order>
</helloconfig>
</tabs>
</config>
**Alanstormdotcom\Helloworld\etc\config.xml**
<?xml version="1.0"?>
<config>
<modules>
<Alanstormdotcom_Helloworld>
<version>0.1.0</version>
</Alanstormdotcom_Helloworld>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Alanstormdotcom_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
<global>
<helpers>
<class>Alanstormdotcom_Helloworld_Helper</class>
</helpers>
</global>
</config>
I just wanted to learn.. I know this works in you but still help me find why.. i might miss
something.. Thank you.

This bit is wrong:
<global>
<helpers>
<class>Alanstormdotcom_Helloworld_Helper</class>
</helpers>
</global>
It should be:
<global>
<helpers>
<helloworld>
<class>Alanstormdotcom_Helloworld_Helper</class>
</helloworld>
</helpers>
</global>
(The <helloworld> tag corresponds to module="helloworld" above)

Related

Magento 1.9.4 Third party model override doesn't work

I've been trying for days now to get a rewritten model to function. but it doesn't work, I'm puzzled because all seems to be correct.
___Here's my config file : etek/advancednewslettercoupon/etc/config.xml
<global>
<models>
<advancednewslettercoupon>
<class>Etek_AdvancedNewsletterCoupon_Model</class>
</advancednewslettercoupon>
<advancednewsletter>
<rewrite>
<subscriber>Etek_AdvancedNewsletterCoupon_Model_Subscriber</subscriber>
<rewrite>
</advancednewsletter>
</models>
</global>
__the subscriber model: Etek/AdvancedNewsletterCoupon/Model/Subscriber.php
class Etek_AdvancedNewsletterCoupon_Model_Subscriber extends AW_Advancednewsletter_Model_Subscriber
{
_construct() {
var_dump('Etek Subscriber');die(get_class($this));
}
public function subscribe($email, $segments, $params = array())
{ echo"<pre>";die('Etek Subscriber');
}
___Etek_AdvancedNewsletterCoupon.xml
<?xml version="1.0"?>
<config>
<modules>
<Etek_AdvancedNewsletterCoupon>
<active>true</active>
<codePool>local</codePool>
<depends>
<AW_Advancednewsletter/>
</depends>
</Etek_AdvancedNewsletterCoupon>
</modules>
</config>
I found out that I forgot to close the tag of rewrite:
<rewrite>
<subscriber>Etek_AdvancedNewsletterCoupon_Model_Subscriber</subscriber>
</rewrite>
Now all seems to work fine :)

Backend Module for Magento 1.9.x

i want to build a new module for Magento 1.9.4 that will be shown in the Admin area (catalog).
I programmed the following code, but i dont know how to show this module in the backend (including form tags). I just get a 404 error.
Here is my code with which i started my first module:
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Eron_ChangePricesPerCategory>
<version>0.1.0</version>
</Eron_ChangePricesPerCategory>
</modules>
<frontend>
<routers>
<changepricespercategory>
<use>standard</use>
<args>
<module>Eron_ChangePricesPerCategory</module>
<frontName>changepricespercategory</frontName>
</args>
</changepricespercategory>
</routers>
</frontend>
<admin>
<routers>
<changepricespercategory>
<use>admin</use>
<args>
<module>Eron_ChangePricesPerCategory</module>
<frontName>admin_changepricespercategory</frontName>
</args>
</changepricespercategory>
</routers>
</admin>
<global>
<helpers>
<changepricespercategory>
<class>Eron_ChangePricesPerCategory_Helper</class>
</changepricespercategory>
</helpers>
</global>
<adminhtml>
<layout>
<updates>
<eron_changepricespercategory>
<file>eron_changepricespercategory.xml</file>
</eron_changepricespercategory>
</updates>
</layout>
</adminhtml>
</config>
adminhtml.xml
<?xml version="1.0"?>
<config>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<changepricespercategory_settings translate="title">
<title>Extra Fee Settings</title>
<sort_order>55</sort_order>
</changepricespercategory_settings>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
system.xml
<?xml version="1.0"?>
<config>
<sections>
<changepricespercategory translate="label" module="changepricespercategory">
<label>Artikelpreise pro Kategorie ändern</label>
<tab>catalog</tab>
<frontend_type>text</frontend_type>
<sort_order>999</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<active translate="label">
<label>Aktiviert</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</active>
<title translate="label">
<label>Title</label>
<frontend_type>text</frontend_type>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</title>
<name translate="label">
<label>Name</label>
<frontend_type>text</frontend_type>
<sort_order>30</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</name>
<showmethod translate="label">
<label>Versandart zeigen, auch wenn nicht möglich</label>
<frontend_type>select</frontend_type>
<sort_order>50</sort_order>
<source_model>adminhtml/system_config_source_yesno</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</showmethod>
<specificerrmsg translate="label">
<label>Angezeigte Fehlermeldung</label>
<frontend_type>textarea</frontend_type>
<sort_order>60</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</specificerrmsg>
<sort_order translate="label">
<label>Reihenfolge</label>
<frontend_type>text</frontend_type>
<sort_order>70</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</sort_order>
</fields>
</changepricespercategory>
</sections>
</config>
IndexController.php (in controllers/Adminhtml)
<?php
class Eron_ChangePricesPerCategory_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
/**
* Admin controller index action
*
* #access public
* #return void
*/
public function indexAction() {
$Block = $this->getLayout()->createBlock('changepricespercategory/Adminhtml_changepricespercategory');
$this->loadLayout()
->_addContent($Block)
->renderLayout();
}
}
The Module is shown in the backend... But i when i click on it, I get a 404. Can anybody help me? Maybe there is a good documentation - im new to magento module developement.
More Information: I want to build a module for changing all prices of a category by a percentage (e.g 2% increase).
You can get started from this toturial:
https://bsscommerce.com/confluence/3-simple-steps-to-create-admin-grid-in-magento-1/
If you want to try more features check this one:
https://www.codealist.com/magento-1-9-x-create-an-adminhtml-controller/

Create cron job for every five minutes?

I am new to Magento 1.9. I have my own custom API which read last modified Product stock and do some updates. I need to make this API run every five minutes . Please help.
Here i mentioned module.
create Stackoverflow_Cronshedule.xml under app\etc\modules\
<?xml version="1.0"?>
<config>
<modules>
<Stackoverflow_Cronshedule>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Stackoverflow_Cronshedule>
</modules>
</config>
create etc.xml under app\code\local\Stackoverflow\Cronshedule\etc\
<?xml version="1.0"?>
<config>
<modules>
<Stackoverflow_Cronshedule>
<version>0.1.0</version>
</Stackoverflow_Cronshedule>
</modules>
<global>
<models>
<cronshedule>
<class>Stackoverflow_Cronshedule_Model</class>
<resourceModel>cronshedule_mysql4</resourceModel>
</cronshedule>
</models>
</global>
<crontab>
<jobs>
<cronshedule_lastmodifiedproduct>
<schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
<run><model>cronshedule/cron::lastModifiedProduct</model></run>
</cronshedule_lastmodifiedproduct>
</jobs>
</crontab>
</config>
Create Cron.php file under app\code\local\Stackoverflow\Cronshedule\Model\
<?php
class Stackoverflow_Cronshedule_Model_Cron{
public function lastModifiedProduct(){
// update last modified product
}
}
At last, Set cron task for every minute in your cPanel for your /cron.php file.

How can I make my enable or disable dropdown box work for my custom extension?

I have made a query extension where you can ask your query, and then get a reply from admin. And I have already managed to get the extension setting tab added as a tab in the admin configuration area, and created "Product Query" menu also.
successfully created this tab
Here are all of my files :)
app/code/local/Vlabs/Productquery/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Vlabs_Productquery>
<version>0.1.0</version>
</Vlabs_Productquery>
</modules>
<frontend>
<routers>
<productquery>
<use>standard</use>
<args>
<module>Vlabs_Productquery</module>
<frontName>productquery</frontName>
</args>
</productquery>
</routers>
<layout>
<updates>
<productquery module="Vlabs_Productquery">
<file>productquery.xml</file>
</productquery>
</updates>
</layout>
</frontend>
<global>
<blocks>
<productquery>
<class>Vlabs_Productquery_Block</class>
</productquery>
</blocks>
<models>
<productquery>
<class>Vlabs_Productquery_Model</class>
<resourceModel>productquery_Resource</resourceModel>
</productquery>
<productquery_Resource>
<class>Vlabs_Productquery_Model_Resource</class>
<entities>
<querybox>
<table>Vlabs_queryBox</table>
</querybox>
</entities>
</productquery_Resource>
</models>
<helpers>
<productquery>
<class>Vlabs_Productquery_Helper</class>
</productquery>
</helpers>
<resources>
<form_setup>
<setup>
<module>Vlabs_Productquery</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</form_setup>
<form_write>
<connection>
<use>core_write</use>
</connection>
</form_write>
<form_read>
<connection>
<use>core_read</use>
</connection>
</form_read>
</resources>
<template>
<email>
<vlabs_query_email_template translate="label">
<label>Recurring order email</label>
<file>vlabs_querybox_email.html</file>
<type>html</type>
</vlabs_query_email_template>
</email>
</template>
</global>
<admin>
<routers>
<adminhtml>
<use>admin</use>
<args>
<modules>
<Vlabs_Productquery before="Mage_Adminhtml">Vlabs_Productquery_Adminhtml</Vlabs_Productquery>
</modules>
<frontname>productquery</frontname>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<layout>
<updates>
<productquery>
<file>productquery.xml</file>
</productquery>
</updates>
</layout>
</adminhtml>
</config>
app/code/local/Vlabs/Productquery/etc/adminhtml.xml
<config>
<menu>
<productquery>
<title>Product Query</title>
<sort_order>50</sort_order>
<children>
<query>
<title>Query</title>
<sort_order>1</sort_order>
<action>adminhtml/index/</action>
</query>
<settings>
<title>Settings</title>
<sort_order>2</sort_order>
<action>adminhtml/index/settings</action>
</settings>
</children>
</productquery>
</menu>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<productquery>
<title>Beckin Drop Down Shipping Extension</title>
</productquery>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
app/code/local/Vlabs/Productquery/etc/system.xml
<?xml version="1.0"?>
<config>
<tabs>
<productquery translate="label">
<label>Vyrazu Query Extension</label>
<sort_order>100</sort_order>
</productquery>
</tabs>
<sections>
<productquery translate="label" module="productquery">
<label>Query</label>
<tab>productquery</tab>
<frontend_type>text</frontend_type>
<sort_order>1000</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<settings translate="label" module="productquery">
<label>Settings</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<enable translate="label">
<label>Enable</label>
<comment>
<![CDATA[Enable or Disable this extension.]]>
</comment>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</enable>
</fields>
</settings>
</groups>
</productquery>
</sections>
</config>
Please guide me, where I should write those code,by this i can disable or enable this extension with this disable/enable dropdown.
I solved the issue.May be someone will be helpfull by this answer. That's why I update my answer.
So,at first write this anywhere to check it is working or not
$enableorDisable = Mage::getStoreConfig('productquery/settings/enable',Mage::app()->getStore());
print_r($enableorDisable); die();
if answer is 0 when your module is disable and answer is 1, when your module is enable. then it is working fine.. And you have to add following line in your block.
<action method="setTitle" translate="value" ifconfig="productquery/settings/enable"><value>Product Query</value></action>
add ifconfig="modulename/group name/field name"
Thank You..

Magento 1.9 :: Custom Module Admin Menu Not Displaying Items

I have an issue on Magento 1.9.
I've just created a custom admin module, but menu items don't appear.
app/etc/modules/Pluma_Storico.xml
<?xml version="1.0" ?>
<config>
<modules>
<Pluma_Storico>
<active>true</active>
<codePool>local</codePool>
</Pluma_Storico>
</modules>
</config>
app/code/local/Pluma/Storico/etc/config.xml
<?xml version="1.0" ?>
<config>
<modules>
<Pluma_Storico>
<version>0.1.0</version>
</Pluma_Storico>
</modules>
</config>
app/code/local/Pluma/Storico/etc/adminhtml.xml
<?xml version="1.0" ?>
<config>
<menu>
<sales>
<children>
<storico module="pluma_storico">
<title>Storico</title>
<sort_order>10</sort_order>
<action>adminhtml/storico/index</action>
</storico>
</children>
</sales>
</menu>
</config>