VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: skotman on August 28, 2013, 00:59:40 AM

Title: Can not modify products from frontend
Post by: skotman on August 28, 2013, 00:59:40 AM
I just upgraded my VM to 2.0.22b from 2.0.22a and noticed I have this error when I try to edit a product from the front end:

Fatal error: Using $this when not in object context in \administrator\components\com_virtuemart\helpers\vmview.php on line 366

I'm running Joomla 2.5.14, I don't know if this issue existed in 2.0.22a since I'm still in development of my site. Any help would be appreciated, I did a quick google and came up with one other person reporting this error from Italy:
http://forum.vmitalia.net/index.php?topic=11694.0

If he's already posted his error over here as directed by someone else please point me to that thread, no need for duplicate threads.
Title: Re: Can not modify products from frontend
Post by: attiliog on August 28, 2013, 11:17:37 AM
PHP: 5.3.5
Joomla!: 2.5.14
Virtuemart: 2.0.22b
Local machine: Macintosh

I'm the Italian user quoted in the previous post. This is my first post here. I report below what I wrote in the Italian forum.

I upgraded an on line site to last versions of Joomla and VirtueMart. Then I tried to edit a product from frontend as administrator. I received a blank page. I thought something went wrong during the upgrade. So I installed a clean version of Joomla and Virtuemart with only the sample data on a local machine. Same behavior. I activated the error reporting on Joomla and I got this error:
Fatal error: Using $this when not in object context in /Applications/MAMP/htdocs/vm2022b/administrator/components/com_virtuemart/helpers/vmview.php on line 366

I verified the code in the file reported by the message: there is an if statement that was not there before, in the 2.0.22a version. Moreover, when I deactivated the if statement, the error didn't show anymore and I edited the product without problems.

I hope this helps.
Title: Re: Can not modify products from frontend
Post by: skotman on August 29, 2013, 21:01:20 PM
It looks like there is another user with the same issue:

http://forum.virtuemart.net/index.php?topic=118296.0
Title: Re: Can not modify products from frontend
Post by: skotman on September 02, 2013, 05:14:18 AM
I took out the If statement, now the page shows up but the changes arn't saved. Are you seeing the same thing?
Title: Re: Can not modify products from frontend
Post by: alatak on September 02, 2013, 09:38:03 AM
Hello
Txs for reporting

I have fixed it.
We should have a new version 2.0.22c this week.
The fix will be included.

Here is the fix for those who cannot wait
in file administrator/components/com_virtuemart/helpers/vmview.php
replace line 366 with
if ($vmView->canDo->get('core.admin') || $vmView->canDo->get('vm.'.$view.'.edit')) {


In file /Applications/MAMP/htdocs/VM2/VM2014MP/administrator/components/com_virtuemart/helpers/adminui.php
replace  line 29 with
   static function startAdminArea($vmView,$selectText = 'COM_VIRTUEMART_DRDOWN_AVA2ALL') {


and then replace all occurence of
AdminUIHelper::startAdminArea();

with
AdminUIHelper::startAdminArea($this);
Title: Re: Can not modify products from frontend
Post by: attiliog on September 02, 2013, 11:42:25 AM
Really thanks for your answer. Only a little thing. You say:

Quote from: alatak on September 02, 2013, 09:38:03 AM
and then replace all occurence of
AdminUIHelper::startAdminArea();

with
AdminUIHelper::startAdminArea($this);


In what files do we need to replace it? I tried in the two files you reported in your post, but i found no occurrence.
Sorry if this is an obvious thing: I'm a novice, as you can see.
Title: Re: Can not modify products from frontend
Post by: alatak on September 02, 2013, 12:12:12 PM
Hello
IN all the files where you have that code
AdminUIHelper::startAdminArea();
It is actually in all the tmpl files
Title: Re: Can not modify products from frontend
Post by: skotman on September 02, 2013, 14:50:25 PM
Quote from: skotman on September 02, 2013, 05:14:18 AM
I took out the If statement, now the page shows up but the changes arn't saved. Are you seeing the same thing?

I was able to fix the changes not being saved by turning off Search Engine Friendly URLs in the global config.
Title: Re: Can not modify products from frontend
Post by: optmax on September 07, 2013, 18:20:21 PM
Joomla 2.5.14
VM 2.0.22c

Just to confirm that even with the 2.0.22c release I can still only edit products in the front end if Joomla! SEO is turned off.