STDERR PHP Fatal error: Call to undefined method Customer::isOwnStudents() - php

[STDERR] PHP Fatal error: Call to undefined method Customer::isOwnStudents() in /upload/catalog/view/theme/Super_green/template/common/header.tpl on line 62
header.tpl looks like
<?php
if ($this->customer->isLogged()) {
if($this->customer->isOwnStudents()>0) echo $orderfood;
echo $language . $currency . $cart . $konto;`}
?>
class ModelAccountStudents extends Model {
public function isOwnStudents() {
$results = $this->getStudentses();
if(sizeof($results)>0) return true;
else return false;
}
What is wrong here in this code. I do not know why do I get this err.

From your code, it looks like $this->customer is an instance of Customer - you've defined the isOwnStudents() method for the ModelAccountStudents class, not the Customer class.

Related

How can I call a function that is defined outside of a class from inside a class

So I haven't really tried much, as I'm new to OOP, all I tried is to make a function for setting the progress bar for an action. When I call it from inside the class it says the function doesn't exist. How can I get around this? Thanks!
If I don't call the function in a class the progress bars works fine.
function progresSet($parama, $paramb) {
code to set prgress;
}
class register {
function a(dasdsadasd) {
progressSet('50', 'red');
}
}
ERRORS
Fatal error: Uncaught Error: Call to undefined function progressSet() in /home/xkhckrzf/xenonmc/controller/controllers/register/main.php:280 Stack trace: #0 /home/xkhckrzf/xenonmc/controller/controllers/register/main.php(382): registerCntlr->main() #1 {main} thrown in /home/xkhckrzf/xenonmc/controller/controllers/register/main.php on line 280
You had some typos but sure you can, take a look:
<?php
function progressSet($parama, $paramb) {
echo $parama . " - " . $paramb;
}
class register {
function classFunction($param1, $param2) {
progressSet($param1, $param2);
}
}
$register = new register();
$register->classFunction('50', 'red')
?>

PHP: Dynamically call default method

There's the following (example) class:
class klasse
{
private $var = 'doit';
function doit($param)
{
return md5($param);
}
function bla($param)
{
// HERES THE PROBLEM
return $this->{$this->var}($param);
}
}
// Create new instance
$klasse = new klasse;
// Start the "dynamical output"
echo $klasse->bla('test');
This works fine! But the problem is that I'd like to call the md5() function "directly dynamically". So I don't want to go the detour with "doit()".
If I try
private $var = 'md5';
at the beginning of the class I get the following (absolutely senseful) error message:
Fatal error: Call to undefined method klasse::md5() in - on line 13
So I know that this error is senseful but I have no clue how to avoid it?
How can I handle this (to directly call md5())?
Thank you!
This should work:
class klasse
{
public function __construct() {
$this->var = 'md5';
}
}
$klasse = new klasse;
echo call_user_func($klasse->var, 'argument');
More info at: http://php.net/manual/en/function.call-user-func.php

Magento Fatal Error

Its my first try with Magento.
I get this Error Message:
Fatal error: Call to a member function append() on a non-object in /var/customers/webs/magento/magento/app/code/core/Mage/Install/controllers/WizardController.php on line 77
Maybe someone have an Idee or can help me with my Problem?
Now the whole Code from Line 68 - 79:
protected function _prepareLayout()
{
$this->loadLayout('install_wizard');
$step = $this->_getWizard()->getStepByRequest($this->getRequest());
if ($step) {
$step->setActive(true);
}
$leftBlock = $this->getLayout()->createBlock('install/state', 'install.state');
$this->getLayout()->getBlock('left')->append($leftBlock);
return $this;
}
Its the orginal code i havenĀ“t edit anything
$this->getLayout()->getBlock('left')
should return a block class or NULL.
If it returned a block class then :
abstract class Mage_Core_Block_Abstract extends Varien_Object
has function
append($leftBlock);
This means that your $this->getLayout()->getBlock('left')
is not return a block instance.
Why not do a mage log of what $this->getLayout()->getBlock('left')
returns and confirm.

Fatal error: Call to a member function deleteCustomer() on a non-object in

I'm new to PHP and Magento, I'm trying to delete a Customer from Magento and I get this error -
Fatal error: Call to a member function deleteCustomer() on a non-object in /home/c42gor/public_html/app/code/local/Braintree/controllers/CustomerController.php on line 30
At other times I get -
Fatal error: Call to a member function deleteCustomer() on a non-object in /home/c42gor/public_html/app/code/local/Braintree/controllers/CustomerController.php on line 15
The CustomerController.php file contains this code -
<?php
require('Mage/Adminhtml/controllers/CustomerController.php');
class Braintree_CustomerController extends Mage_Adminhtml_CustomerController
{
public function deleteAction()
{
$braintree = Mage::getModel('braintree/paymentMethod');
$customerId = $this->getRequest()->getParam('id');
if ($customerId)
{
$braintree->deleteCustomer($customerId);
}
parent::deleteAction();
}
public function massDeleteAction()
{
$customerIds = $this->getRequest()->getParam('customer');
if(is_array($customerIds))
{
$braintree = Mage::getModel('braintree/paymentMethod');
foreach ($customerIds as $customerId)
{
$braintree->deleteCustomer($customerId);
}
}
parent::massDeleteAction();
}
}
Change
$braintree = Mage::getModel('braintree/paymentMethod');
To
$braintree = Mage::getModel('braintree/paymentmethod');
Then rename
/app/code/local/Braintree/{Modulename}/Model/PaymentMethod.php
To
/app/code/local/Braintree/{Modulename}/Model/Paymentmethod.php
Then change the class name by edit file /app/code/local/Braintree/{Modulename}/Model/Paymentmethod.php
Change
class Braintree_{Modulename}_Model_PaymentMethod ...
To
class Braintree_{Modulename}_Model_Paymentmethod ...
you shall not use camel case class names like paymentMethod!
$braintree = Mage::getModel('braintree/paymentMethod');
Rename your class to Paymentmethod.php, rename the class label inside the class file accordingly.
Then do a
$braintree = Mage::getModel('braintree/paymentmethod');
Mage::log(get_class(braintree);
if the result in the Mage::log is empty you made a mistake with you factory...
Good luck!

Codeigniter model Undefined property

i have following code in the controller file which check for post varible pdf and execute following code
if(isset($_POST['pdf']) && $_POST['pdf']=="pdf")
{
$this->load->model('voutput_model');
$final_view = $data['frmReport'];
$PDF_Name = "report.pdf";
$this->votput_model->pdf($PDF_Name,$final_view);
}
I have following code in model file
class Voutput_model extends CI_Model{
public function __construct()
{
parent::__construct();
$this->CI = get_instance();
}
public function pdf($file_name,$filecontents){
$this->pdf_path = $this->config->item('pdf_path');
$this->load->library('htmltopdf/Html2fpdf');
$file['Attach_path'] = $this->pdf_path.$file_name;
$this->html2fpdf->generate_pdf($file['Attach_path'],$filecontents,'Y');
}
}
while i am executing the code i am getting error as below:
Severity: Notice
Message: Undefined property: Voutput::$Voutput_model
Filename: controllers/voutput.php
Fatal error: Call to a member function pdf() on a non-object in
C:\xampp\htdocs\asset\application\controllers\voutput.php
You need to load model before use . Try this
$this->load->model('votput_model');
$this->votput_model->pdf($PDF_Name,$final_view);

Categories