Magento Fatal Error - php

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.

Related

Codeigniter - Cannot access property started with '\0' error

I am calling function form library in codeigniter and it's giving me below error
PHP Fatal error: Cannot access property started with '\0' in /system/core/Exceptions.php on line 85
Code:
$this->load->library('test_library');
TEST_LIBRARY::first();
Class file:
class TEST_LIBRARY
{
public function first(){
return "here";
}
}
However, when I call the function using this method $this->test_library->first(); it's working fine.
It was working both ways before not sure what's going on. There is no other log messages in error.log file. How can I debug further and fix this issue?
Function first is not static but you called as if it is. Change test_libaray.php to :
class TEST_LIBRARY {
public function __construct() {}
public function first() {
return "here"; // i suggest to use __METHOD__ or __LINE__ instead
}
}
And then try:
$test_library = new TEST_LIBRARY();
$test_libaray->first();
instead of:
TEST_LIBRARY::first();
Or you can just change first static.

How to set mysqli_result::num_rows

For mocking purposes, I extended the mysqli_result class:
class MysqliResultMock extends mysqli_result {
...
}
Now, I need to override what it returns for its member called 'num_rows', but unfortunately with $this->num_rows = 123; it's simply not settable (I get a fatal error for writing this line:
Fatal error: Cannot directly set the property MysqliResultMock::$num_rows in DbTest.php on line 13)
Can it be done somehow?
Thank you.
Haha, I figured out the answer.
You just need to add the public $num_rows; line to the class, explicitly, to make it writable. Like this:
class result extends mysqli_result {
public $num_rows;
public function __construct()
{
$this->num_rows = 6;
...
then you can call mysql_num_rows() on an instance and it will return the given num_rows properly.

Trying to get property of non-object in PHP

I'm working with PHP and get error message:
Notice: Trying to get property of non-object in D:\xampp\htdocs\gmbr\fw\model\UserModel.php on line 234
This is my code:
# Static user
public static function is_admin()
{
return self::$auth->admin?true:false; // <<- This line 234
}
public static function username()
{
return self::$auth->username;
}
Probably what's going on is that the $auth object isn't initialized yet when your method is called.
Use a var_dump(self::$auth) to see what's going on.
If this is the case, I would use a Singleton design pattern with $auth, Running a self::getAuth() instead of self::$auth.

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

[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.

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!

Categories