Magento Fatal error: Call to a member function addLink() - magento

Whenever I try to do something in a popup window, live export or preview a transactioanl email I get an error:
Fatal error: Call to a member function addLink() on a non-object in
/home/jsrdirec/public_html/app/code/core/Mage/Adminhtml/Block/Widget.php
on line 65
Here is app/code/core/Mage/Adminhtml/Block/Widget.php:
protected function _addBreadcrumb($label, $title=null, $link=null)
{
$this->getLayout()->getBlock('breadcrumbs')->addLink($label, $title, $link);
}
Does anyone have any idea what could be causing this?

There can be so many reasons for this , check this question for more information. Mean while you can try this hack to fix your problem.

I had this same problem. I noticed it when I was trying to import products through the import interface. The kicker was that two days before the problem started, everything was working fine. My solution, as a temporary fix, was I edited the _addBreadCrumb function in app/code/core/Mage/Adminhtml/Block/Widget.php to be
protected function _addBreadcrumb($label, $title=null, $link=null)
{
if($this->getLayout()->getBlock('breadcrumbs')){
$this->getLayout()->getBlock('breadcrumbs')->addLink($label, $title, $link);
}
}
For me, I didn't care if there were breadcrumbs on the admin page, specifically when importing products or sending emails. So far, it hasn't caused a problem on the store site itself. Breadcrumbs are still generating as expected, I can still add to cart, checkout, etc.
PLEASE NOTE - This is changing a core class in a core class file, which is not the best/borderline bad if not bad. So I want to emphasize this is/should be a TEMPORARY fix only!!

Related

Laravel Error screen, what file throws the error and what file to fix?

I really like to understand where the problem is in my project and I love Laravel, but at the same time it makes it so difficult to find WHERE the problem comes from.
I don't understand if is a lack of knowledge on my part (perhaps so) or if I need to have some magic wand to understand WHAT FILE is throwing the error.
I'm currently working with 3 classes:
HttpClientContract.php in App\Services\Http folder
HttpClient.php in App\Services\Http folder
HttpClientServiceProvider.php in App\Providers folder
Probably I misnamed something or called a wrong path but the error I have is the following:
From here I do understand I called Class App\Services\HttpClientContract that does not exist, fine. But WHERE did I do that mistake? :(
It says is in the ...src/Illuminate/Routing/RouteSignatureParameters.php which is probably the sub container Class or so, but I do not know where MY mistake is.
[edit]
Of course being a RouteSignatureParameters.php I can think of routes/web.php file. But I'll give you another example:
In this Laracast lesson at minute 7:20 the routes/web.php is composed of this:
Route::get('/', function(){
dd(app('example'));
});
The Example Class is not imported nor bound to the App Container therefore this errors fires this:
The file I need to fix is web.php in the routes folder, but Laravel Error handling doesn't tell me this, so how do I figure it out?
Is there a way to show up in what file actually needs fixing?
Actually laravel does tell you which file is responsible for the error. The red box in below image is your whole call stack (backtracing) and the file that generated the error is somewhere between that
To make it easier you can change the call stack only to application frame and it'll be easier to find the file where you made the mistake.
and this is the 35th line of App\Http\Controllers\HomeController.php file
35 app('example');
36
37 return view('home');
When you make syntax error or something similar it'll be straight forward (check the image, just one file), but if the error is like that you made is different because the error didn't happened until the non-existent class was being tried to instantiate which is why you get a long list of call stack.

Laravel created_by/modified_by relations

I was trying to get this working in a typical belongsTo relation. However it keeps saying that the column is not set in the model, even if looking in the actual database it is there.
I have tried to look at the source code as well as try many approaches to bypass this issue, however nothing seems to do anything.
public function modifiedBy()
{
return $this->belongsTo('\Modules\Users\Model\User', 'modified_by');
}
public function createdBy()
{
return $this->belongsTo('\Modules\Users\Model\User', 'created_by');
}
This is the code inside the model, I use PSR-0 to define modules, better splitting up logic (no issues with that) but using this it would give an error of
Undefined property: \Modules\Module\Model\CurrentModel::$modified_by
This is coming from a seed to push some initial info into the database.
$user = Sentinel::findById(1);
$model = new CurrentModel;
$model->modifiedBy()->associate($user);
$model->save();
This is basically how it goes together, I have tried for some time to figure out what is wrong but I am calling blanks. Any ideas?
Found out a solution. Not a fix though but I would consider this an issue with laravel so I may look into adding it as a bug report (although this could be fixed in laravel 5?).
Basically with modified_by I need to define the column it is using and not let laravel automatically generate it (in order to do this "cleanly"). However the "bug" (only calling it a bug as currently I can only see this as an unintended problem) makes it so you cannot define the column it will be using, you have to let laravel decide it for you.
So I changed the functions to look like this:
public function modifiedby()
{
return $this->belongsTo('\Modules\Users\Model\User');
}
This makes laravel assume the column is modifiedby_id, but by changing my migrations to reflect that there was no more error.

Joomla - call function model within the model

In a public function of my model I call
$user_type=$this->get_user_type();
In the same model I have
private function get_user_type()
{
$user_type='asd';
$asd_groups = (int)$config->get('asd_groups');
$ver_groups = (int)$config->get('ver_groups');
jimport( 'joomla.user.helper' );
$user_groups=JUserHelper::getUserGroups($user->id);
if(in_array($asd_groups,$user_groups)){
$user_type='asd';
}
if(in_array($ver_groups,$user_groups)){
$user_type='ver';
}
return $user_type;
}
The site give me a white page, if I comment the calling line "$this->get_user_type();" then it works...
I really don't understand what is wrong here.
There is not enough information or code here to help you… for example where is $config coming from and what is it? What version of Joomla is this on?
If $config is not defined as a global then that may be the source of the problem depending on your PHP setup.
Things you can do to help yourself find the problem, in Joomla's Global Configuration.
Set Error Messages to "Development" in Joomla (you are using a development site and not a live website right?)
Turn on Joomla's DEBUG mode
Then update your question with details of error messages, Joomla version and where this code is running (you say your model) and where $config is coming from.
Oh sure!
I have missed the two configuration variable when i moved the code from inside a function in a dedicated function.
I copied these two lines on the first row of the function and now it works!
$config = JComponentHelper::getParams(S_APP_NAME);
$user = JFactory::getUser ();

Laravel 4: Multiple Action in a Single Contnroller Not Working?

I am new to Laravel and am just stuck upon this thing. I have set a controller which contains multiple actions for application. It turns out that if I put a single action in a single controller class, it works quite well. But when I use multiple action. It gives that damn error "Whoops, looks like something went wrong."
So, exactly what am I doing wrong? below is my controller class:
<? php
class ProgController extends BaseController
{
public function showHome()
{
return View::make('home');
}
public function showLogin()
{
return ('you are not authorized to login yet');
}
public function showTravel()
{
return View::make('travel');
}
}
and here is the route.php file content:
Route::get('/', 'ProgController#showHome');
Route::get('/login', 'ProgController#showLogin');
Route::get('/travel', 'ProgController#showTravel');
the files are in their respective default folders. I am worried has it something to do with composer.json file or what? what am I doing wrong?
Turn on debugging in your app/config/app.php file. Make sure you have a home.blade.php or home.php file in app/views (same applies for travel.blade.php or travel.php).
Unless we can see a stack trace that's the best we can give you for now. Definitely turn on debugging for a dev environment.
Use server log, it'll tell you the exact error when you have 500 like this "Whoops, looks like something went wrong.". Most likely you have one component which is not configured right or missing class, missing model, or anything which Laravel can not capture in application level.

Joomla 2.5 Load custom field in components layout fatal error

Im trying to load custom field in my backend component default view (default.php):
JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
$productType = JFormHelper::loadFieldType('ProductType',false);
$productTypeOptions = $productType->getOptions();
But I get a fatal error:
Fatal error: Call to a member function children() on a non-object in xxx\libraries\joomla\form\fields\list.php on line 89
When I load this custom field into the form, everything works perfectly.
Any ideas?
Make sure you are adding the correct path to the fields
In your $productType->getOptions() function,
Try removing:
$options = array_merge(parent::getOptions(), $options);
Well, I tried to expand my fellow above idea but it seemed an inappropiate edit, I put it here then:
This worked for me. In your getOptions, if you have something like the getOptions found here (http://docs.joomla.org/How_to_add_custom_filters_to_component_admin), you´ll have this line:
$options = array_merge(parent::getOptions(), $options);
This is the one that makes the error. Why? Well, I´m not sure. If you see the related file, you´ll find this:
foreach ($this->element->children() as $option)
So the problem is that you are calling children() on the model parent that it seems is not initialized. Why the array_merge is needed? Is discussed here (http://forum.joomla.org/viewtopic.php?f=626&t=782877)
My explanation is more like a dirty blind patch, but hope it helps to move forward.

Resources