Organizational Research By

Surprising Reserch Topic

magento not allowing more than one function in one class


magento not allowing more than one function in one class  using -'php,mysql,sql,magento,zend-framework'

I have been building a magneto plugin, and there seems to be a problem with this class functions. Not entirely sure why the following function cause the site to go into a server error 500??

Now this class is included in the config.xml. It set up so when you click save config the function ... is called. THAT function works fine, however when i include the other two functions below the entire webpage goes to the error page when save config is clicked. ANY IDEAS!!

<?php
class Envato_CustomConfig_Model_Observer
{

    public function adminSystemConfigChangedSection()
    {           
        $tablename_c = Mage::getStoreConfig('customconfig_options/section_one/custom_field_one');
        $email = Mage::getStoreConfig('customconfig_options/section_two/custom_field_two');
        $days = Mage::getStoreConfig('customconfig_options/section_two/custom_field_three');

        $bind = array(
            'id'    => ' ',
            'tablename_c'   => $tablename_c,
            'email' => $email,
            'days'    => $days,
            'timeStamp' => now(),
        );

        //Open Database Conenction
        $write = Mage::getSingleton("core/resource")->getConnection("core_write");

        $query = "
        insert into Envato_CustomConfig_Job (Job_Id, tablename_colummname, email_template, days, timeStamp)
        values (:id, :tablename_c, :email, :days, :timeStamp);
        ";

        $write->query($query, $bind);

        $res = "
        SELECT Job_Id, tablename_colummname, email_template, days  FROM Envato_CustomConfig_Job
        WHERE tablename_colummname = :tablename_c
        AND email_template = :email
        AND days = :days
        AND timeStamp =:timeStamp
        AND Job_Id != :id
        LIMIT 1;
        ";

        $result = $write->query($res, $bind);

        return Envato_CustomConfig_Model_Observer::runningJobs($result);
    }


When the following two fucntions below are in the class the entire page crashes.

        public function toDateFormat($time,$format)
    {
        $dateAndTime = $time;       
        if($format == 1)
        {
            $dateAndTime = date('M d, Y', $dateAndTime);
            return $dateAndTime;
        }elseif($format == 2)
        {
            $dateAndTime = strtotime($time);
            $dateAndTime = date('M d, Y', $dateAndTime);
            return $dateAndTime;
        }else
        {
            $dateAndTime = strtotime($time);
            return $dateAndTime;
        }
    }


    public function runningJobs($res)
    {   
        $result = $res;
        foreach($result as $record) {

            $Job_Id = $record['Job_Id'];
            $tablename_colummname = $record['tablename_colummname'];
            $days = $record['days'];
            $email_template = $record['email_template'];

            $email_Details[] = explode(".",$tablename_colummname);          
            $count = count($email_Details);

            if($count < 2)
            {
                $email_Details['2'] = time();
                $email_Details['2'] = Envato_CustomConfig_Helper_Data::toDateFormat($email_Details['2'],1);
            }
        }

        $bind = array(
            'Job_Id'    => $Job_Id,
            'tableName'   => $email_Details['0'],
            'email' => $email_Details['1'],
            'email_template' => $email_template,
            'days' => $days,
            'timeStamp' => $email_Details['2'],
        );

        //Open Database Conenction
        $write = Mage::getSingleton("core/resource")->getConnection("core_write");

        $query = "
        insert into Envato_CustomConfig_Job (Job_Id, tableName, email, email_template, days, timeStamp)
        values (:Job_Id, :tableName, :email, :email_template, :days, :timeStamp);
        ";

        $write->query($query, $bind);

        return $bind;
    }
}
?>


EDIT:: I HAVE ADDED MY XML CONFIG JUST INCASE THE ERROR IS HERE?

<?xml version = "1.0"?>
<config>
    <modules>
        <Envato_CustomConfig>
            <version>0.0.1</version>
        </Envato_CustomConfig>
    </modules>
    <global>
        <events>
            <admin_system_config_changed_section_customconfig_options>
                <observers>
                    <customconfig>
                        <type>singleton</type>
                        <class>customconfig/observer</class>
                        <method>adminSystemConfigChangedSection</method>
                    </customconfig>
                </observers>
            </admin_system_config_changed_section_customconfig_options>
        </events>

        <helpers>
            <customconfig>
                <class>Envato_CustomConfig_Helper</class>
            </customconfig>
        </helpers>
        <models>
            <customconfig>
                <class>Envato_CustomConfig_Model</class>
            </customconfig>
        </models>
        <resources>
            <customconfig_setup>
                <setup>
                    <module>Envato_CustomConfig</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </customconfig_setup>
            <customconfig_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </customconfig_write>
            <customconfig_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </customconfig_read>
        </resources>
    </global>
    <adminhtml>
        <acl>
            <resources>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <customconfig_options>
                                            <title>Email Configuration Section</title>
                                        </customconfig_options>
                                    </children>
                                </config>
                            </children>
                        </system>
                    </children>
                </admin>
            </resources>
        </acl>
    </adminhtml>
</config>

    

asked Oct 23, 2015 by deepak
0 votes
1 view



Related Hot Questions

2 Answers

0 votes

Missing semicolons

$email_template = $record['email_template']

and here

$email_Details['2'] = Envato_CustomConfig_Helper_Data::toDateFormat($email_Details['2'],1)

typo here

$email_Details['2'] = strtotime(now());

Use a better IDE ;)

answered Oct 23, 2015 by tushar2k6
0 votes

If you got error 500, first thing you ll have to do is check your logs. Have a look on /var/log, and you ll probably have errors ( i guess system.log but look at the more recent one).

Then if you bring us informations, we will be able to help you, but you ll probably even fix it yourself! :)

answered Oct 23, 2015 by virendra.bajaj

...